“1d4f49253ddf51a850f9c4a4542a33eb1b19bf9e”上不存在“en/application-dev/ui/ui-js-components-switch.md”
提交 50ffd9d0 编写于 作者: D dy_study

Update API9 docs.

Signed-off-by: Ndy_study <dingyao5@huawei.com>
Change-Id: Ief4c02cd2d301989616e233478c8fff38647fc75
上级 b8eab4d8
...@@ -331,8 +331,8 @@ ...@@ -331,8 +331,8 @@
| startAbilityByCall(want:&nbsp;Want):&nbsp;Promise&lt;Caller&gt;; | 启动指定UIAbility至前台或后台,同时获取其Caller通信接口,调用方可使用Caller与被启动的Ability进行通信。 | | startAbilityByCall(want:&nbsp;Want):&nbsp;Promise&lt;Caller&gt;; | 启动指定UIAbility至前台或后台,同时获取其Caller通信接口,调用方可使用Caller与被启动的Ability进行通信。 |
| on(method:&nbsp;string,&nbsp;callback:&nbsp;CalleeCallBack):&nbsp;void | 通用组件Callee注册method对应的callback方法。 | | on(method:&nbsp;string,&nbsp;callback:&nbsp;CalleeCallBack):&nbsp;void | 通用组件Callee注册method对应的callback方法。 |
| off(method:&nbsp;string):&nbsp;void | 通用组件Callee解注册method的callback方法。 | | off(method:&nbsp;string):&nbsp;void | 通用组件Callee解注册method的callback方法。 |
| call(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Sequenceable):&nbsp;Promise&lt;void&gt; | 向通用组件Callee发送约定序列化数据。 | | call(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;void&gt; | 向通用组件Callee发送约定序列化数据。 |
| callWithResult(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Sequenceable):&nbsp;Promise&lt;rpc.MessageParcel&gt; | 向通用组件Callee发送约定序列化数据,&nbsp;并将Callee返回的约定序列化数据带回。 | | callWithResult(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;rpc.MessageSequence&gt; | 向通用组件Callee发送约定序列化数据,&nbsp;并将Callee返回的约定序列化数据带回。 |
| release():&nbsp;void | 释放通用组件的Caller通信接口。 | | release():&nbsp;void | 释放通用组件的Caller通信接口。 |
| on(type:&nbsp;"release",&nbsp;callback:&nbsp;OnReleaseCallback):&nbsp;void | 注册通用组件通信断开监听通知。 | | on(type:&nbsp;"release",&nbsp;callback:&nbsp;OnReleaseCallback):&nbsp;void | 注册通用组件通信断开监听通知。 |
...@@ -401,7 +401,7 @@ ...@@ -401,7 +401,7 @@
```ts ```ts
export default class MySequenceable { export default class MyParcelable {
num: number = 0 num: number = 0
str: string = "" str: string = ""
...@@ -410,15 +410,15 @@ ...@@ -410,15 +410,15 @@
this.str = string this.str = string
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num) messageSequence.writeInt(this.num)
messageParcel.writeString(this.str) messageSequence.writeString(this.str)
return true return true
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt() this.num = messageSequence.readInt()
this.str = messageParcel.readString() this.str = messageSequence.readString()
return true return true
} }
} }
...@@ -434,13 +434,13 @@ ...@@ -434,13 +434,13 @@
console.info('CalleeSortFunc called') console.info('CalleeSortFunc called')
// 获取Caller发送的序列化数据 // 获取Caller发送的序列化数据
let receivedData = new MySequenceable(0, '') let receivedData = new MyParcelable(0, '')
data.readSequenceable(receivedData) data.readParcelable(receivedData)
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`)
// 作相应处理 // 作相应处理
// 返回序列化数据result给Caller // 返回序列化数据result给Caller
return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`) return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`)
} }
export default class CalleeAbility extends Ability { export default class CalleeAbility extends Ability {
...@@ -500,13 +500,13 @@ ...@@ -500,13 +500,13 @@
getRemoteDeviceId方法参照[通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据](#通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据)。 getRemoteDeviceId方法参照[通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据](#通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据)。
5. 向被调用端UIAbility发送约定序列化数据。 5. 向被调用端UIAbility发送约定序列化数据。
1. 向被调用端发送Sequenceable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Callee被调用端发送数据。 1. 向被调用端发送Parcelable数据有两种方式,一种是不带返回值,一种是获取被调用端返回的数据,method以及序列化数据需要与被调用端协商一致。如下示例调用Call接口,向Callee被调用端发送数据。
```ts ```ts
const MSG_SEND_METHOD: string = 'CallSendMsg' const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() { async onButtonCall() {
try { try {
let msg = new MySequenceable(1, 'origin_Msg') let msg = new MyParcelable(1, 'origin_Msg')
await this.caller.call(MSG_SEND_METHOD, msg) await this.caller.call(MSG_SEND_METHOD, msg)
} catch (error) { } catch (error) {
console.info(`caller call failed with ${error}`) console.info(`caller call failed with ${error}`)
...@@ -521,12 +521,12 @@ ...@@ -521,12 +521,12 @@
backMsg: string = '' backMsg: string = ''
async onButtonCallWithResult(originMsg, backMsg) { async onButtonCallWithResult(originMsg, backMsg) {
try { try {
let msg = new MySequenceable(1, originMsg) let msg = new MyParcelable(1, originMsg)
const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg) const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg)
console.info('caller callWithResult succeed') console.info('caller callWithResult succeed')
let result = new MySequenceable(0, '') let result = new MyParcelable(0, '')
data.readSequenceable(result) data.readParcelable(result)
backMsg(result.str) backMsg(result.str)
console.info(`caller result is [${result.num}, ${result.str}]`) console.info(`caller result is [${result.num}, ${result.str}]`)
} catch (error) { } catch (error) {
......
...@@ -469,8 +469,8 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe ...@@ -469,8 +469,8 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
| startAbilityByCall(want:&nbsp;Want):&nbsp;Promise&lt;Caller&gt; | 启动指定UIAbility并获取其Caller通信接口,默认为后台启动,通过配置want可实现前台启动,详见[接口文档](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall)。AbilityContext与ServiceExtensionContext均支持该接口。 | | startAbilityByCall(want:&nbsp;Want):&nbsp;Promise&lt;Caller&gt; | 启动指定UIAbility并获取其Caller通信接口,默认为后台启动,通过配置want可实现前台启动,详见[接口文档](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall)。AbilityContext与ServiceExtensionContext均支持该接口。 |
| on(method:&nbsp;string,&nbsp;callback:&nbsp;CalleeCallBack):&nbsp;void | 通用组件Callee注册method对应的callback方法。 | | on(method:&nbsp;string,&nbsp;callback:&nbsp;CalleeCallBack):&nbsp;void | 通用组件Callee注册method对应的callback方法。 |
| off(method:&nbsp;string):&nbsp;void | 通用组件Callee解注册method的callback方法。 | | off(method:&nbsp;string):&nbsp;void | 通用组件Callee解注册method的callback方法。 |
| call(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Sequenceable):&nbsp;Promise&lt;void&gt; | 向通用组件Callee发送约定序列化数据。 | | call(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;void&gt; | 向通用组件Callee发送约定序列化数据。 |
| callWithResult(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Sequenceable):&nbsp;Promise&lt;rpc.MessageParcel&gt; | 向通用组件Callee发送约定序列化数据,&nbsp;并将Callee返回的约定序列化数据带回。 | | callWithResult(method:&nbsp;string,&nbsp;data:&nbsp;rpc.Parcelable):&nbsp;Promise&lt;rpc.MessageSequence&gt; | 向通用组件Callee发送约定序列化数据,&nbsp;并将Callee返回的约定序列化数据带回。 |
| release():&nbsp;void | 释放通用组件的Caller通信接口。 | | release():&nbsp;void | 释放通用组件的Caller通信接口。 |
| on(type:&nbsp;"release",&nbsp;callback:&nbsp;OnReleaseCallback):&nbsp;void | 注册通用组件通信断开监听通知。 | | on(type:&nbsp;"release",&nbsp;callback:&nbsp;OnReleaseCallback):&nbsp;void | 注册通用组件通信断开监听通知。 |
...@@ -518,7 +518,7 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe ...@@ -518,7 +518,7 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
```ts ```ts
export default class MySequenceable { export default class MyParcelable {
num: number = 0 num: number = 0
str: string = "" str: string = ""
...@@ -527,15 +527,15 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe ...@@ -527,15 +527,15 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
this.str = string this.str = string
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num) messageSequence.writeInt(this.num)
messageParcel.writeString(this.str) messageSequence.writeString(this.str)
return true return true
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt() this.num = messageSequence.readInt()
this.str = messageParcel.readString() this.str = messageSequence.readString()
return true return true
} }
} }
...@@ -553,13 +553,13 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe ...@@ -553,13 +553,13 @@ Call功能主要接口如下表所示。具体的API详见[接口文档](../refe
console.info('CalleeSortFunc called'); console.info('CalleeSortFunc called');
// 获取Caller发送的序列化数据 // 获取Caller发送的序列化数据
let receivedData = new MySequenceable(0, ''); let receivedData = new MyParcelable(0, '');
data.readSequenceable(receivedData); data.readParcelable(receivedData);
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`); console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
// 作相应处理 // 作相应处理
// 返回序列化数据result给Caller // 返回序列化数据result给Caller
return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`); return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
} }
export default class CalleeAbility extends Ability { export default class CalleeAbility extends Ability {
......
...@@ -321,7 +321,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -321,7 +321,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | 是 | 约定的服务端注册事件字符串。 | | method | string | 是 | 约定的服务端注册事件字符串。 |
| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | 是 | 由开发者实现的Sequenceable可序列化数据。 | | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | 是 | 由开发者实现的Parcelable可序列化数据。 |
**返回值:** **返回值:**
...@@ -339,7 +339,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -339,7 +339,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
**示例:** **示例:**
```ts ```ts
class MyMessageAble{ // 自定义的Sequenceable数据结构 class MyMessageAble{ // 自定义的Parcelable数据结构
name:'' name:''
str:'' str:''
num: 1 num: 1
...@@ -347,15 +347,15 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -347,15 +347,15 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -370,7 +370,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -370,7 +370,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
deviceId: '' deviceId: ''
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
let msg = new MyMessageAble('msg', 'world'); // 参考Sequenceable数据定义 let msg = new MyMessageAble('msg', 'world'); // 参考Parcelable数据定义
caller.call(method, msg) caller.call(method, msg)
.then(() => { .then(() => {
console.log('Caller call() called'); console.log('Caller call() called');
...@@ -390,7 +390,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -390,7 +390,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
## Caller.callWithResult ## Caller.callWithResult
callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParcel&gt;; callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequence&gt;;
向通用组件服务端发送约定序列化数据, 并将服务端返回的约定序列化数据带回。 向通用组件服务端发送约定序列化数据, 并将服务端返回的约定序列化数据带回。
...@@ -401,13 +401,13 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc ...@@ -401,13 +401,13 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | 是 | 约定的服务端注册事件字符串。 | | method | string | 是 | 约定的服务端注册事件字符串。 |
| data | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | 是 | 由开发者实现的Sequenceable可序列化数据。 | | data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | 是 | 由开发者实现的Parcelable可序列化数据。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Promise&lt;[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)&gt; | Promise形式返回通用组件服务端应答数据。 | | Promise&lt;[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)&gt; | Promise形式返回通用组件服务端应答数据。 |
**错误码:** **错误码:**
...@@ -427,15 +427,15 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc ...@@ -427,15 +427,15 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -455,7 +455,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc ...@@ -455,7 +455,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParc
.then((data) => { .then((data) => {
console.log('Caller callWithResult() called'); console.log('Caller callWithResult() called');
let retmsg = new MyMessageAble(0, ''); let retmsg = new MyMessageAble(0, '');
data.readSequenceable(retmsg); data.readParcelable(retmsg);
}) })
.catch((callErr) => { .catch((callErr) => {
console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) + console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) +
...@@ -725,8 +725,8 @@ on(method: string, callback: CalleeCallback): void; ...@@ -725,8 +725,8 @@ on(method: string, callback: CalleeCallback): void;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | 是 | 与客户端约定的通知消息字符串。 | | method | string | 是 | 与客户端约定的通知消息字符串。 |
| callback | [CalleeCallback](#calleecallback) | 是 | 一个[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)类型入参的js通知同步回调函数,&nbsp;回调函数至少要返回一个空的[rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated)数据对象,&nbsp;其他视为函数执行错误。 | | callback | [CalleeCallback](#calleecallback) | 是 | 一个[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)类型入参的js通知同步回调函数,&nbsp;回调函数至少要返回一个空的[rpc.Parcelable](js-apis-rpc.md#parcelable9)数据对象,&nbsp;其他视为函数执行错误。 |
**错误码:** **错误码:**
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
...@@ -745,15 +745,15 @@ on(method: string, callback: CalleeCallback): void; ...@@ -745,15 +745,15 @@ on(method: string, callback: CalleeCallback): void;
this.name = name; this.name = name;
this.str = str; this.str = str;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']'); console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
return true; return true;
} }
...@@ -762,7 +762,7 @@ on(method: string, callback: CalleeCallback): void; ...@@ -762,7 +762,7 @@ on(method: string, callback: CalleeCallback): void;
function funcCallBack(pdata) { function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata); console.log('Callee funcCallBack is called ' + pdata);
let msg = new MyMessageAble('test', ''); let msg = new MyMessageAble('test', '');
pdata.readSequenceable(msg); pdata.readParcelable(msg);
return new MyMessageAble('test1', 'Callee test'); return new MyMessageAble('test1', 'Callee test');
} }
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
...@@ -829,10 +829,10 @@ off(method: string): void; ...@@ -829,10 +829,10 @@ off(method: string): void;
## CalleeCallback ## CalleeCallback
(indata: rpc.MessageParcel): rpc.Parcelable; (indata: rpc.MessageSequence): rpc.Parcelable;
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore **系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 可读 | 可写 | 类型 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | 是 | 否 | [rpc.Parcelable](js-apis-rpc.md#parcelabledeprecated) | 被调用方注册的消息侦听器函数接口的原型。 | | (indata: [rpc.MessageSequence](js-apis-rpc.md#messagesequence9)) | 是 | 否 | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | 被调用方注册的消息侦听器函数接口的原型。 |
...@@ -345,7 +345,7 @@ function stopContinuousTask() { ...@@ -345,7 +345,7 @@ function stopContinuousTask() {
} }
} }
class MySequenceable { class MyParcelable {
num: number = 0; num: number = 0;
str: String = ""; str: String = "";
...@@ -354,23 +354,23 @@ class MySequenceable { ...@@ -354,23 +354,23 @@ class MySequenceable {
this.str = string; this.str = string;
} }
marshalling(messageParcel) { marshalling(messageSequence) {
messageParcel.writeInt(this.num); messageSequence.writeInt(this.num);
messageParcel.writeString(this.str); messageSequence.writeString(this.str);
return true; return true;
} }
unmarshalling(messageParcel) { unmarshalling(messageSequence) {
this.num = messageParcel.readInt(); this.num = messageSequence.readInt();
this.str = messageParcel.readString(); this.str = messageSequence.readString();
return true; return true;
} }
} }
function sendMsgCallback(data) { function sendMsgCallback(data) {
console.info('BgTaskAbility funcCallBack is called ' + data) console.info('BgTaskAbility funcCallBack is called ' + data)
let receivedData = new MySequenceable(0, "") let receivedData = new MyParcelable(0, "")
data.readSequenceable(receivedData) data.readParcelable(receivedData)
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`)
// 可以根据Caller端发送的序列化数据的str值,执行不同的方法。 // 可以根据Caller端发送的序列化数据的str值,执行不同的方法。
if (receivedData.str === 'start_bgtask') { if (receivedData.str === 'start_bgtask') {
...@@ -378,7 +378,7 @@ function sendMsgCallback(data) { ...@@ -378,7 +378,7 @@ function sendMsgCallback(data) {
} else if (receivedData.str === 'stop_bgtask') { } else if (receivedData.str === 'stop_bgtask') {
stopContinuousTask(); stopContinuousTask();
} }
return new MySequenceable(10, "Callee test"); return new MyParcelable(10, "Callee test");
} }
export default class BgTaskAbility extends Ability { export default class BgTaskAbility extends Ability {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册