Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
91b73876
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
91b73876
编写于
1月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!13215 更新事件通知文档
Merge pull request !13215 from yangliang36/yl0104
上级
0953f840
d8b288b9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
156 addition
and
155 deletion
+156
-155
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
+55
-56
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
...lication-dev/reference/apis/js-apis-commonEventManager.md
+63
-61
zh-cn/application-dev/reference/apis/js-apis-emitter.md
zh-cn/application-dev/reference/apis/js-apis-emitter.md
+1
-1
zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md
...-dev/reference/errorcodes/errorcode-CommonEventService.md
+37
-37
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
浏览文件 @
91b73876
...
...
@@ -40,7 +40,7 @@ publish(event: string, callback: AsyncCallback<void>): void
```
ts
//发布公共事件回调
function
publishC
allBack
(
err
)
{
function
publishC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -49,7 +49,7 @@ function publishCallBack(err) {
}
//发布公共事件
CommonEvent
.
publish
(
"
event
"
,
publishC
allBack
);
CommonEvent
.
publish
(
"
event
"
,
publishC
B
);
```
## CommonEvent.publish
...
...
@@ -82,7 +82,7 @@ let options = {
}
//发布公共事件回调
function
publishC
allBack
(
err
)
{
function
publishC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -91,7 +91,7 @@ function publishCallBack(err) {
}
//发布公共事件
CommonEvent
.
publish
(
"
event
"
,
options
,
publishC
allBack
);
CommonEvent
.
publish
(
"
event
"
,
options
,
publishC
B
);
```
## CommonEvent.publishAsUser<sup>8+</sup>
...
...
@@ -118,7 +118,7 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): voi
```
ts
//发布公共事件回调
function
publish
AsUserCallBack
(
err
)
{
function
publish
CB
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -130,7 +130,7 @@ function publishAsUserCallBack(err) {
let
userId
=
100
;
//发布公共事件
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
publish
AsUserCallBack
);
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
publish
CB
);
```
## CommonEvent.publishAsUser<sup>8+</sup>
...
...
@@ -165,7 +165,7 @@ let options = {
}
//发布公共事件回调
function
publish
AsUserCallBack
(
err
)
{
function
publish
CB
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -177,7 +177,7 @@ function publishAsUserCallBack(err) {
let
userId
=
100
;
//发布公共事件
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
options
,
publish
AsUserCallBack
);
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
options
,
publish
CB
);
```
## CommonEvent.createSubscriber
...
...
@@ -209,7 +209,7 @@ let subscribeInfo = {
};
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
create
CB
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -219,7 +219,7 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
CB
);
```
## CommonEvent.createSubscriber
...
...
@@ -290,7 +290,7 @@ let subscribeInfo = {
};
//订阅公共事件回调
function
subscribeC
allBack
(
err
,
data
)
{
function
subscribeC
B
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
error
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -299,19 +299,18 @@ function subscribeCallBack(err, data) {
}
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventS
ubscriber
)
{
function
create
CB
(
err
,
s
ubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
CommonEvent
.
subscribe
(
subscriber
,
subscribeC
allBack
);
CommonEvent
.
subscribe
(
subscriber
,
subscribeC
B
);
}
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
CB
);
```
## CommonEvent.unsubscribe
...
...
@@ -342,7 +341,7 @@ let subscribeInfo = {
};
//订阅公共事件回调
function
subscribeC
allBack
(
err
,
data
)
{
function
subscribeC
B
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -351,19 +350,19 @@ function subscribeCallBack(err, data) {
}
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
create
CB
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
CommonEvent
.
subscribe
(
subscriber
,
subscribeC
allBack
);
CommonEvent
.
subscribe
(
subscriber
,
subscribeC
B
);
}
}
//取消订阅公共事件回调
function
unsubscribeC
allBack
(
err
)
{
function
unsubscribeC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -372,10 +371,10 @@ function unsubscribeCallBack(err) {
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
create
CB
);
//取消订阅公共事件
CommonEvent
.
unsubscribe
(
subscriber
,
unsubscribeC
allBack
);
CommonEvent
.
unsubscribe
(
subscriber
,
unsubscribeC
B
);
```
## CommonEventSubscriber
...
...
@@ -402,14 +401,14 @@ getCode(callback: AsyncCallback<number>): void
let
subscriber
;
//创建成功的订阅者对象
//获取有序公共事件的结果代码回调
function
getCodeC
allback
(
err
,
Code
)
{
function
getCodeC
B
(
err
,
Code
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getCode failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
Code
));
}
}
subscriber
.
getCode
(
getCodeC
allback
);
subscriber
.
getCode
(
getCodeC
B
);
```
### getCode
...
...
@@ -433,8 +432,8 @@ getCode(): Promise<number>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getCode
().
then
((
C
ode
)
=>
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
C
ode
));
subscriber
.
getCode
().
then
((
c
ode
)
=>
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
c
ode
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getCode failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -463,14 +462,14 @@ setCode(code: number, callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的结果代码回调
function
setCodeC
allback
(
err
)
{
function
setCodeC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCode failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
setCode
"
);
}
}
subscriber
.
setCode
(
1
,
setCodeC
allback
);
subscriber
.
setCode
(
1
,
setCodeC
B
);
```
### setCode
...
...
@@ -529,15 +528,15 @@ getData(callback: AsyncCallback<string>): void
let
subscriber
;
//创建成功的订阅者对象
//获取有序公共事件的结果数据回调
function
getDataC
allback
(
err
,
D
ata
)
{
function
getDataC
B
(
err
,
d
ata
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
D
ata
));
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
d
ata
));
}
}
subscriber
.
getData
(
getDataC
allback
);
subscriber
.
getData
(
getDataC
B
);
```
### getData
...
...
@@ -561,8 +560,8 @@ getData(): Promise<string>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getData
().
then
((
D
ata
)
=>
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
D
ata
));
subscriber
.
getData
().
then
((
d
ata
)
=>
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
d
ata
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getData failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -591,14 +590,14 @@ setData(data: string, callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的结果数据回调
function
setDataC
allback
(
err
)
{
function
setDataC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
setData
"
);
}
}
subscriber
.
setData
(
"
publish_data_changed
"
,
setDataC
allback
);
subscriber
.
setData
(
"
publish_data_changed
"
,
setDataC
B
);
```
### setData
...
...
@@ -659,7 +658,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的结果代码和结果数据回调
function
setCodeDataC
allback
(
err
)
{
function
setCodeDataC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCodeAndData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -667,7 +666,7 @@ function setCodeDataCallback(err) {
}
}
subscriber
.
setCodeAndData
(
1
,
"
publish_data_changed
"
,
setCodeDataC
allback
);
subscriber
.
setCodeAndData
(
1
,
"
publish_data_changed
"
,
setCodeDataC
B
);
```
### setCodeAndData
...
...
@@ -729,14 +728,14 @@ isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前公共事件是否为有序事件的回调
function
isOrderedC
allback
(
err
,
isOrdered
)
{
function
isOrderedC
B
(
err
,
isOrdered
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isOrderedCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
isOrdered
"
+
JSON
.
stringify
(
isOrdered
));
}
}
subscriber
.
isOrderedCommonEvent
(
isOrderedC
allback
);
subscriber
.
isOrderedCommonEvent
(
isOrderedC
B
);
```
### isOrderedCommonEvent
...
...
@@ -793,14 +792,14 @@ isStickyCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前公共事件是否为粘性事件的回调
function
isStickyC
allback
(
err
,
isSticky
)
{
function
isStickyC
B
(
err
,
isSticky
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isStickyCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
isSticky
"
+
JSON
.
stringify
(
isSticky
));
}
}
subscriber
.
isStickyCommonEvent
(
isStickyC
allback
);
subscriber
.
isStickyCommonEvent
(
isStickyC
B
);
```
### isStickyCommonEvent
...
...
@@ -855,7 +854,7 @@ abortCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//取消当前有序公共事件的回调
function
abortC
allback
(
err
)
{
function
abortC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
abortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -863,7 +862,7 @@ function abortCallback(err) {
}
}
subscriber
.
abortCommonEvent
(
abortC
allback
);
subscriber
.
abortCommonEvent
(
abortC
B
);
```
### abortCommonEvent
...
...
@@ -916,7 +915,7 @@ clearAbortCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//清除当前公共事件取消状态的回调
function
clearAbortC
allback
(
err
)
{
function
clearAbortC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
clearAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -924,7 +923,7 @@ function clearAbortCallback(err) {
}
}
subscriber
.
clearAbortCommonEvent
(
clearAbortC
allback
);
subscriber
.
clearAbortCommonEvent
(
clearAbortC
B
);
```
### clearAbortCommonEvent
...
...
@@ -977,15 +976,15 @@ getAbortCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前有序公共事件是否取消的回调
function
getAbortC
allback
(
err
,
AbortCommon
Event
)
{
function
getAbortC
B
(
err
,
abort
Event
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
AbortCommonEvent
"
+
AbortCommon
Event
)
console
.
info
(
"
abortEvent
"
+
abort
Event
)
}
}
subscriber
.
getAbortCommonEvent
(
getAbortC
allback
);
subscriber
.
getAbortCommonEvent
(
getAbortC
B
);
```
### getAbortCommonEvent
...
...
@@ -1009,8 +1008,8 @@ getAbortCommonEvent(): Promise<boolean>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getAbortCommonEvent
().
then
((
A
bortCommonEvent
)
=>
{
console
.
info
(
"
AbortCommonEvent
"
+
JSON
.
stringify
(
A
bortCommonEvent
));
subscriber
.
getAbortCommonEvent
().
then
((
a
bortCommonEvent
)
=>
{
console
.
info
(
"
abortCommonEvent
"
+
JSON
.
stringify
(
a
bortCommonEvent
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -1038,15 +1037,15 @@ getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
let
subscriber
;
//创建成功的订阅者对象
//获取订阅者信息回调
function
get
SubscribeInfoCallback
(
err
,
S
ubscribeInfo
)
{
function
get
CB
(
err
,
s
ubscribeInfo
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getSubscribeInfo failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
SubscribeInfo
"
+
JSON
.
stringify
(
S
ubscribeInfo
));
console
.
info
(
"
SubscribeInfo
"
+
JSON
.
stringify
(
s
ubscribeInfo
));
}
}
subscriber
.
getSubscribeInfo
(
get
SubscribeInfoCallback
);
subscriber
.
getSubscribeInfo
(
get
CB
);
```
### getSubscribeInfo
...
...
@@ -1070,8 +1069,8 @@ getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getSubscribeInfo
().
then
((
S
ubscribeInfo
)
=>
{
console
.
info
(
"
SubscribeInfo
"
+
JSON
.
stringify
(
S
ubscribeInfo
));
subscriber
.
getSubscribeInfo
().
then
((
s
ubscribeInfo
)
=>
{
console
.
info
(
"
subscribeInfo
"
+
JSON
.
stringify
(
s
ubscribeInfo
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getSubscribeInfo failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -1099,7 +1098,7 @@ finishCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//结束当前有序公共事件的回调
function
finishC
ommonEventCallback
(
err
)
{
function
finishC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
finishCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -1107,7 +1106,7 @@ function finishCommonEventCallback(err) {
}
}
subscriber
.
finishCommonEvent
(
finishC
ommonEventCallback
);
subscriber
.
finishCommonEvent
(
finishC
B
);
```
### finishCommonEvent<sup>9+</sup>
...
...
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
浏览文件 @
91b73876
...
...
@@ -43,7 +43,7 @@ publish(event: string, callback: AsyncCallback<void>): void
```
ts
//发布公共事件回调
function
publishC
allBack
(
err
)
{
function
publishC
B
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -53,7 +53,7 @@ function publishCallBack(err) {
//发布公共事件
try
{
CommonEventManager
.
publish
(
"
event
"
,
publishC
allBack
);
CommonEventManager
.
publish
(
"
event
"
,
publishC
B
);
}
catch
(
err
)
{
console
.
error
(
'
publish failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -92,7 +92,7 @@ let options = {
}
//发布公共事件回调
function
publishC
allBack
(
err
)
{
function
publishC
B
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -102,7 +102,7 @@ function publishCallBack(err) {
//发布公共事件
try
{
CommonEventManager
.
publish
(
"
event
"
,
options
,
publishC
allBack
);
CommonEventManager
.
publish
(
"
event
"
,
options
,
publishC
B
);
}
catch
(
err
)
{
console
.
error
(
'
publish failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -136,7 +136,7 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): voi
```
ts
//发布公共事件回调
function
publish
AsUserCallBack
(
err
)
{
function
publish
CB
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -149,7 +149,7 @@ let userId = 100;
//发布公共事件
try
{
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
publish
AsUserCallBack
);
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
publish
CB
);
}
catch
(
err
)
{
console
.
error
(
'
publishAsUser failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -191,7 +191,7 @@ let options = {
}
//发布公共事件回调
function
publish
AsUserCallBack
(
err
)
{
function
publish
CB
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -204,7 +204,7 @@ let userId = 100;
//发布公共事件
try
{
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
options
,
publish
AsUserCallBack
);
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
options
,
publish
CB
);
}
catch
(
err
)
{
console
.
error
(
'
publishAsUser failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -239,7 +239,7 @@ let subscribeInfo = {
};
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
create
CB
(
err
,
commonEventSubscriber
)
{
if
(
!
err
)
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
...
...
@@ -250,7 +250,7 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
CB
);
}
catch
(
err
)
{
console
.
error
(
'
createSubscriber failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -326,7 +326,7 @@ let subscribeInfo = {
};
//订阅公共事件回调
function
SubscribeC
allBack
(
err
,
data
)
{
function
SubscribeC
B
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
error
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -335,13 +335,12 @@ function SubscribeCallBack(err, data) {
}
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventS
ubscriber
)
{
function
create
CB
(
err
,
s
ubscriber
)
{
if
(
!
err
)
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
try
{
CommonEventManager
.
subscribe
(
subscriber
,
SubscribeC
allBack
);
CommonEventManager
.
subscribe
(
subscriber
,
SubscribeC
B
);
}
catch
(
err
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
...
...
@@ -352,7 +351,7 @@ function createSubscriberCallBack(err, commonEventSubscriber) {
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
CB
);
}
catch
(
err
)
{
console
.
error
(
'
createSubscriber failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -384,7 +383,7 @@ let subscribeInfo = {
events
:
[
"
event
"
]
};
//订阅公共事件回调
function
subscribeC
allBack
(
err
,
data
)
{
function
subscribeC
B
(
err
,
data
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -392,22 +391,21 @@ function subscribeCallBack(err, data) {
}
}
//创建订阅者回调
function
create
SubscriberCallBack
(
err
,
commonEventS
ubscriber
)
{
function
create
CB
(
err
,
s
ubscriber
)
{
if
(
err
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
try
{
CommonEventManager
.
subscribe
(
subscriber
,
subscribeC
allBack
);
CommonEventManager
.
subscribe
(
subscriber
,
subscribeC
B
);
}
catch
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
}
}
//取消订阅公共事件回调
function
unsubscribeC
allBack
(
err
)
{
function
unsubscribeC
B
(
err
)
{
if
(
err
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -416,14 +414,14 @@ function unsubscribeCallBack(err) {
}
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
SubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
create
CB
);
}
catch
(
err
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
//取消订阅公共事件
try
{
CommonEventManager
.
unsubscribe
(
subscriber
,
unsubscribeC
allBack
);
CommonEventManager
.
unsubscribe
(
subscriber
,
unsubscribeC
B
);
}
catch
(
err
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
...
...
@@ -453,14 +451,14 @@ getCode(callback: AsyncCallback<number>): void
let
subscriber
;
//创建成功的订阅者对象
//获取有序公共事件代码回调
function
getCodeC
allback
(
err
,
C
ode
)
{
function
getCodeC
B
(
err
,
c
ode
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getCode failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
C
ode
));
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
c
ode
));
}
}
subscriber
.
getCode
(
getCodeC
allback
);
subscriber
.
getCode
(
getCodeC
B
);
```
### getCode
...
...
@@ -484,8 +482,8 @@ getCode(): Promise<number>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getCode
().
then
((
C
ode
)
=>
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
C
ode
));
subscriber
.
getCode
().
then
((
c
ode
)
=>
{
console
.
info
(
"
getCode
"
+
JSON
.
stringify
(
c
ode
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getCode failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -493,7 +491,9 @@ subscriber.getCode().then((Code) => {
### setCode
setCode(code: number, callback: AsyncCallback
\<
void>): void
```
ts
setCode
(
code
:
number
,
callback
:
AsyncCallback
<
void
>
):
void
```
以回调形式设置公共事件的代码。
...
...
@@ -512,14 +512,14 @@ setCode(code: number, callback: AsyncCallback\<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的代码回调
function
setCodeC
allback
(
err
)
{
function
setCodeC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCode failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
setCode
"
);
}
}
subscriber
.
setCode
(
1
,
setCodeC
allback
);
subscriber
.
setCode
(
1
,
setCodeC
B
);
```
### setCode
...
...
@@ -578,14 +578,14 @@ getData(callback: AsyncCallback<string>): void
let
subscriber
;
//创建成功的订阅者对象
//获取有序公共事件代码数据回调
function
getDataC
allback
(
err
,
D
ata
)
{
function
getDataC
B
(
err
,
d
ata
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
D
ata
));
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
d
ata
));
}
}
subscriber
.
getData
(
getDataC
allback
);
subscriber
.
getData
(
getDataC
B
);
```
### getData
...
...
@@ -609,8 +609,8 @@ getData(): Promise<string>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getData
().
then
((
D
ata
)
=>
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
D
ata
));
subscriber
.
getData
().
then
((
d
ata
)
=>
{
console
.
info
(
"
getData
"
+
JSON
.
stringify
(
d
ata
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getData failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -637,14 +637,14 @@ setData(data: string, callback: AsyncCallback\<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的结果数据回调
function
setDataC
allback
(
err
)
{
function
setDataC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
setData
"
);
}
}
subscriber
.
setData
(
"
publish_data_changed
"
,
setDataC
allback
);
subscriber
.
setData
(
"
publish_data_changed
"
,
setDataC
B
);
```
### setData
...
...
@@ -705,14 +705,14 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//设置有序公共事件的代码和数据回调
function
setCodeDataC
allback
(
err
)
{
function
setCodeDataC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
setCodeAndData failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
setCodeDataCallback
"
);
}
}
subscriber
.
setCodeAndData
(
1
,
"
publish_data_changed
"
,
setCodeDataC
allback
);
subscriber
.
setCodeAndData
(
1
,
"
publish_data_changed
"
,
setCodeDataC
B
);
```
### setCodeAndData
...
...
@@ -774,20 +774,20 @@ isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前公共事件是否为有序事件的回调
function
isOrderedC
allback
(
err
,
isOrdered
)
{
function
isOrderedC
B
(
err
,
isOrdered
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isOrderedCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
isOrdered
"
+
JSON
.
stringify
(
isOrdered
));
}
}
subscriber
.
isOrderedCommonEvent
(
isOrderedC
allback
);
subscriber
.
isOrderedCommonEvent
(
isOrderedC
B
);
```
### isOrderedCommonEvent
```
ts
isOrderedCommonEvent
():
Promise
\
<
boolean
>
isOrderedCommonEvent
():
Promise
<
boolean
>
```
以Promise形式查询当前公共事件的是否为有序公共事件。
...
...
@@ -838,14 +838,14 @@ isStickyCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前公共事件是否为粘性事件的回调
function
isStickyC
allback
(
err
,
isSticky
)
{
function
isStickyC
B
(
err
,
isSticky
)
{
if
(
err
.
code
)
{
console
.
error
(
"
isStickyCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
isSticky
"
+
JSON
.
stringify
(
isSticky
));
}
}
subscriber
.
isStickyCommonEvent
(
isStickyC
allback
);
subscriber
.
isStickyCommonEvent
(
isStickyC
B
);
```
### isStickyCommonEvent
...
...
@@ -900,14 +900,14 @@ abortCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//取消当前有序公共事件的回调
function
abortC
allback
(
err
)
{
function
abortC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
abortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
abortCommonEvent
"
);
}
}
subscriber
.
abortCommonEvent
(
abortC
allback
);
subscriber
.
abortCommonEvent
(
abortC
B
);
```
### abortCommonEvent
...
...
@@ -960,14 +960,14 @@ clearAbortCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//清除当前公共事件取消状态的回调
function
clearAbortC
allback
(
err
)
{
function
clearAbortC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
clearAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
clearAbortCommonEvent
"
);
}
}
subscriber
.
clearAbortCommonEvent
(
clearAbortC
allback
);
subscriber
.
clearAbortCommonEvent
(
clearAbortC
B
);
```
### clearAbortCommonEvent
...
...
@@ -1020,14 +1020,14 @@ getAbortCommonEvent(callback: AsyncCallback<boolean>): void
let
subscriber
;
//创建成功的订阅者对象
//获取当前有序公共事件是否取消的回调
function
getAbortC
allback
(
err
,
AbortCommon
Event
)
{
function
getAbortC
B
(
err
,
abort
Event
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
AbortCommonEvent
"
+
AbortCommon
Event
)
console
.
info
(
"
abortCommonEvent
"
+
abort
Event
)
}
}
subscriber
.
getAbortCommonEvent
(
getAbortC
allback
);
subscriber
.
getAbortCommonEvent
(
getAbortC
B
);
```
### getAbortCommonEvent
...
...
@@ -1051,8 +1051,8 @@ getAbortCommonEvent(): Promise<boolean>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getAbortCommonEvent
().
then
((
AbortCommon
Event
)
=>
{
console
.
info
(
"
AbortCommonEvent
"
+
JSON
.
stringify
(
AbortCommon
Event
));
subscriber
.
getAbortCommonEvent
().
then
((
abort
Event
)
=>
{
console
.
info
(
"
abortCommonEvent
"
+
JSON
.
stringify
(
abort
Event
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getAbortCommonEvent failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -1060,7 +1060,9 @@ subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
### getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback
\<
CommonEventSubscribeInfo>): void
```
ts
getSubscribeInfo
(
callback
:
AsyncCallback
<
CommonEventSubscribeInfo
>
):
void
```
以回调形式获取订阅者的订阅信息。
...
...
@@ -1078,14 +1080,14 @@ getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
let
subscriber
;
//创建成功的订阅者对象
//获取订阅者信息回调
function
get
SubscribeInfoCallback
(
err
,
S
ubscribeInfo
)
{
function
get
CB
(
err
,
s
ubscribeInfo
)
{
if
(
err
.
code
)
{
console
.
error
(
"
getSubscribeInfo failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
SubscribeInfo
"
+
JSON
.
stringify
(
S
ubscribeInfo
));
console
.
info
(
"
subscribeInfo
"
+
JSON
.
stringify
(
s
ubscribeInfo
));
}
}
subscriber
.
getSubscribeInfo
(
get
SubscribeInfoCallback
);
subscriber
.
getSubscribeInfo
(
get
CB
);
```
### getSubscribeInfo
...
...
@@ -1109,8 +1111,8 @@ getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
ts
let
subscriber
;
//创建成功的订阅者对象
subscriber
.
getSubscribeInfo
().
then
((
S
ubscribeInfo
)
=>
{
console
.
info
(
"
SubscribeInfo
"
+
JSON
.
stringify
(
S
ubscribeInfo
));
subscriber
.
getSubscribeInfo
().
then
((
s
ubscribeInfo
)
=>
{
console
.
info
(
"
subscribeInfo
"
+
JSON
.
stringify
(
s
ubscribeInfo
));
}).
catch
((
err
)
=>
{
console
.
error
(
"
getSubscribeInfo failed
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -1138,14 +1140,14 @@ finishCommonEvent(callback: AsyncCallback<void>): void
let
subscriber
;
//创建成功的订阅者对象
//结束当前有序公共事件的回调
function
finishC
ommonEventCallback
(
err
)
{
function
finishC
B
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
finishCommonEvent failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
FinishCommonEvent
"
);
}
}
subscriber
.
finishCommonEvent
(
finishC
ommonEventCallback
);
subscriber
.
finishCommonEvent
(
finishC
B
);
```
### finishCommonEvent<sup>9+</sup>
...
...
zh-cn/application-dev/reference/apis/js-apis-emitter.md
浏览文件 @
91b73876
...
...
@@ -60,7 +60,7 @@ once(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdat
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------------------------ |
| event |
[
InnerEvent
](
#innerevent
)
| 是 | 单次订阅的事件,其中
[
EventPriority
](
#eventpriority
)
,在订阅事件时无需指定,也不生效 |
| callback | Callback
\<
[
EventData
](
#
innerevent
)
\>
| 是 | 接收到该事件时需要执行的回调处理函数 |
| callback | Callback
\<
[
EventData
](
#
eventdata
)
\>
| 是 | 接收到该事件时需要执行的回调处理函数 |
**示例:**
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md
浏览文件 @
91b73876
...
...
@@ -3,125 +3,125 @@
## 1500001 want中Action为空
**错误信息**
Want action is null
>
Want action is null
**错误描述**
发送事件的
`want`
中的
`Action`
属性为空时系统会产生此错误码。
>
发送事件的`want`中的`Action`属性为空时系统会产生此错误码。
**可能原因**
发送事件的
`want`
中的
`Action`
属性为空。
>
发送事件的`want`中的`Action`属性为空。
**处理步骤**
检查传入
`want`
的
`Action`
属性是否为空。
>
检查传入`want`的`Action`属性是否为空。
## 1500002 沙箱应用无法发送公共事件
**错误信息**
sandbox application can not send common event
>
sandbox application can not send common event
**错误描述**
沙箱应用无法发送公共事件。
>
沙箱应用无法发送公共事件。
**可能原因**
事件发送方应用为沙箱应用,发送事件会被拦截。
>
事件发送方应用为沙箱应用,发送事件会被拦截。
**处理步骤**
沙箱应用无法发送公共事件,发送公共事件前确认是否为沙箱应用。
>
沙箱应用无法发送公共事件,发送公共事件前确认是否为沙箱应用。
## 1500003 事件发送频率过高
**错误信息**
common event send frequency too high
>
common event send frequency too high
**错误描述**
应用发送事件过于频繁。
>
应用发送事件过于频繁。
**可能原因**
短时间内应用发送过多事件。
>
短时间内应用发送过多事件。
**处理步骤**
检查应用是否过于频繁地发送事件。
>
检查应用是否过于频繁地发送事件。
## 1500004 无法发送系统公共事件
**错误信息**
not System services or System app
>
not System services or System app
**错误描述**
当前应用无法发送系统公共事件。
>
当前应用无法发送系统公共事件。
**可能原因**
非系统应用或非系统服务发送系统公共事件。
>
非系统应用或非系统服务发送系统公共事件。
**处理步骤**
确认当前应用是否为系统应用,或当前服务是否为系统服务。
>
确认当前应用是否为系统应用,或当前服务是否为系统服务。
## 1500005 未找到订阅者
**错误信息**
subscriber can not found
>
subscriber can not found
**错误描述**
找不到订阅者。
>
找不到订阅者。
**可能原因**
订阅者被删除。
>
订阅者被删除。
**处理步骤**
检查是否有重复取消订阅。
>
检查是否有重复取消订阅。
## 1500006 无效userId
**错误信息**
userId is invalid
>
userId is invalid
**错误描述**
无效的userId。
>
无效的userId。
**可能原因**
和系统
`userId`
不一致或不是系统应用或系统服务进程。
>
和系统`userId`不一致或不是系统应用或系统服务进程。
**处理步骤**
1.
检查当前
`userId`
是否和系统
`userId`
一致。
2.
检查当前应用是否为系统应用或系统服务。
>
1. 检查当前`userId`是否和系统`userId`一致。
>
2. 检查当前应用是否为系统应用或系统服务。
## 1500007 IPC请求发送失败
**错误信息**
message send error
>
message send error
**错误描述**
`IPC`
发送请求失败。
>
`IPC`发送请求失败。
**可能原因**
没有成功创建连接对象。
>
没有成功创建连接对象。
**处理步骤**
请勿频繁建立链接,稍后重新尝试。
>
请勿频繁建立链接,稍后重新尝试。
## 1500008 读取数据失败
**错误信息**
CEMS error
>
CEMS error
**错误描述**
服务端发生错误。
>
服务端发生错误。
**可能原因**
服务端处理数据时发现业务异常。
>
服务端处理数据时发现业务异常。
**处理步骤**
稍后重新尝试。
>
稍后重新尝试。
## 1500009 system error
**错误信息**
system error
>
system error
**错误描述**
处理业务时系统发生异常,如获取系统当前时间失败。
>
处理业务时系统发生异常,如获取系统当前时间失败。
**可能原因**
系统故障,获取系统当前时间发生异常。
>
系统故障,获取系统当前时间发生异常。
**处理步骤**
稍后重新尝试。
>
稍后重新尝试。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录