1 Star 0 Fork 5.3K

maosiping / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
changelog-v3.1-beta.md 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
NEEN 提交于 2021-12-31 18:32 . update release notes

ChangeLog

关键的接口/组件变更

进程间通信子系统

cl.rpc.1 sendRequest返回值类型变更

变更影响

js的RemoteProxy和RemoteObject的sendRequest变更为异步接口,返回Promise,兑现值是SendRequestResult的实例。原有应用需要适配。

关键的接口/组件变更
模块:ohos.rpc.IRemoteObject, ohos.rpc.RemoteProxy和ohos.rpc.RemoteObject
接口:sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean

变更后接口:
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult>

适配指导

import rpc from "@ohos.rpc"

let option = new rpc.MessageOption()
let data = rpc.MessageParcel.create()
let reply = rpc.MessageParcel.create()
proxy.sendRequest(1, data, reply, option)
	.then(function(result) {  
		console.info("send request done")
		if (result.errCode === 0) {
			// read result from result.reply
		}
	})
	.catch(function(e) {
		console.error("send request failed: " + e)
	})
	.finally(() => {
		data.reclaim()
		reply.reclaim()
	})
1
https://gitee.com/maosiping/docs.git
git@gitee.com:maosiping/docs.git
maosiping
docs
docs
master

搜索帮助