未验证 提交 e37715ed 编写于 作者: O openharmony_ci 提交者: Gitee

!23747 guidance ArkTs sample code adaption

Merge pull request !23747 from dufresne_andy/master
...@@ -45,7 +45,7 @@ Extension生命周期回调,在创建时回调,执行初始化业务逻辑 ...@@ -45,7 +45,7 @@ Extension生命周期回调,在创建时回调,执行初始化业务逻辑
```ts ```ts
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
onInit(want) { onInit(want : Want) {
console.log('onInit, want: ${want.abilityName}'); console.log('onInit, want: ${want.abilityName}');
} }
} }
...@@ -96,14 +96,14 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC ...@@ -96,14 +96,14 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
```ts ```ts
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{ class StubTest extends rpc.RemoteObject{
constructor(des) { constructor(des : string) {
super(des); super(des);
} }
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code : number, data : MessageSequence, reply : MessageSequence, option : MessageOption) {
} }
} }
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
onConnect(want) { onConnect(want : Want) {
console.log('onConnect , want: ${want.abilityName}'); console.log('onConnect , want: ${want.abilityName}');
return new StubTest('test'); return new StubTest('test');
} }
...@@ -115,10 +115,10 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC ...@@ -115,10 +115,10 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
```ts ```ts
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{ class StubTest extends rpc.RemoteObject{
constructor(des) { constructor(des : string) {
super(des); super(des);
} }
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code : number, data : MessageSequence, reply : MessageSequence, option : MessageOption) {
} }
} }
async function getDescriptor() { async function getDescriptor() {
...@@ -126,7 +126,7 @@ async function getDescriptor() { ...@@ -126,7 +126,7 @@ async function getDescriptor() {
return "asyncTest" return "asyncTest"
} }
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
async onConnect(want) { async onConnect(want : Want) {
console.log(`onConnect , want: ${want.abilityName}`); console.log(`onConnect , want: ${want.abilityName}`);
let descriptor = await getDescriptor(); let descriptor = await getDescriptor();
return new StubTest(descriptor); return new StubTest(descriptor);
...@@ -152,7 +152,7 @@ Extension的生命周期回调,客户端执行断开连接服务时回调。 ...@@ -152,7 +152,7 @@ Extension的生命周期回调,客户端执行断开连接服务时回调。
```ts ```ts
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
onDisconnect(want) { onDisconnect(want : Want) {
console.log('onDisconnect, want: ${want.abilityName}'); console.log('onDisconnect, want: ${want.abilityName}');
} }
} }
...@@ -162,7 +162,7 @@ Extension的生命周期回调,客户端执行断开连接服务时回调。 ...@@ -162,7 +162,7 @@ Extension的生命周期回调,客户端执行断开连接服务时回调。
```ts ```ts
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
async onDisconnect(want) { async onDisconnect(want : Want) {
console.log('onDisconnect, want: ${want.abilityName}'); console.log('onDisconnect, want: ${want.abilityName}');
// 调用异步函数... // 调用异步函数...
} }
...@@ -188,7 +188,7 @@ onDump(params: Array\<string>): Array\<string>; ...@@ -188,7 +188,7 @@ onDump(params: Array\<string>): Array\<string>;
```ts ```ts
class DriverExt extends DriverExtension { class DriverExt extends DriverExtension {
onDump(params) { onDump(params : Array<string>) {
console.log('dump, params: ${JSON.stringify(params)}'); console.log('dump, params: ${JSON.stringify(params)}');
return ['params']; return ['params'];
} }
......
...@@ -22,7 +22,7 @@ import common from '@ohos.app.ability.common'; ...@@ -22,7 +22,7 @@ import common from '@ohos.app.ability.common';
```ts ```ts
import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility'; import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility';
let context; let context : DriverExtensionContext;
class EntryAbility extends DriverExtensionAbility { class EntryAbility extends DriverExtensionAbility {
onInit() { onInit() {
context = this.context; // 获取DriverExtensionContext context = this.context; // 获取DriverExtensionContext
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册