Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
461fd762
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看板
提交
461fd762
编写于
12月 12, 2022
作者:
Z
zhuhan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
Signed-off-by:
N
zhuhan
<
zhuhan10@huawei.com
>
Change-Id: I8b690f4db2d85015e1f64399786c7fbd3e3b126f
上级
cfb29608
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
38 deletion
+38
-38
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
+20
-20
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
...lication-dev/reference/apis/js-apis-commonEventManager.md
+18
-18
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
浏览文件 @
461fd762
...
...
@@ -192,7 +192,7 @@ publish(event: string, callback: AsyncCallback\<void>): void
```
js
//发布公共事件回调
function
P
ublishCallBack
(
err
)
{
function
p
ublishCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -201,7 +201,7 @@ function PublishCallBack(err) {
}
//发布公共事件
CommonEvent
.
publish
(
"
event
"
,
P
ublishCallBack
);
CommonEvent
.
publish
(
"
event
"
,
p
ublishCallBack
);
```
...
...
@@ -234,7 +234,7 @@ let options = {
}
//发布公共事件回调
function
P
ublishCallBack
(
err
)
{
function
p
ublishCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -243,7 +243,7 @@ function PublishCallBack(err) {
}
//发布公共事件
CommonEvent
.
publish
(
"
event
"
,
options
,
P
ublishCallBack
);
CommonEvent
.
publish
(
"
event
"
,
options
,
p
ublishCallBack
);
```
...
...
@@ -270,7 +270,7 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
```
js
//发布公共事件回调
function
P
ublishAsUserCallBack
(
err
)
{
function
p
ublishAsUserCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -282,7 +282,7 @@ function PublishAsUserCallBack(err) {
let
userId
=
100
;
//发布公共事件
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
P
ublishAsUserCallBack
);
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
p
ublishAsUserCallBack
);
```
...
...
@@ -317,7 +317,7 @@ let options = {
}
//发布公共事件回调
function
P
ublishAsUserCallBack
(
err
)
{
function
p
ublishAsUserCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -329,7 +329,7 @@ function PublishAsUserCallBack(err) {
let
userId
=
100
;
//发布公共事件
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
options
,
P
ublishAsUserCallBack
);
CommonEvent
.
publishAsUser
(
"
event
"
,
userId
,
options
,
p
ublishAsUserCallBack
);
```
...
...
@@ -361,7 +361,7 @@ let subscribeInfo = {
};
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -371,7 +371,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
```
...
...
@@ -442,7 +442,7 @@ let subscribeInfo = {
};
//订阅公共事件回调
function
S
ubscribeCallBack
(
err
,
data
)
{
function
s
ubscribeCallBack
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
error
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -451,19 +451,19 @@ function SubscribeCallBack(err, data) {
}
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
error
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
CommonEvent
.
subscribe
(
subscriber
,
S
ubscribeCallBack
);
CommonEvent
.
subscribe
(
subscriber
,
s
ubscribeCallBack
);
}
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
```
...
...
@@ -494,7 +494,7 @@ let subscribeInfo = {
};
//订阅公共事件回调
function
S
ubscribeCallBack
(
err
,
data
)
{
function
s
ubscribeCallBack
(
err
,
data
)
{
if
(
err
.
code
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -503,19 +503,19 @@ function SubscribeCallBack(err, data) {
}
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
.
code
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
//订阅公共事件
CommonEvent
.
subscribe
(
subscriber
,
S
ubscribeCallBack
);
CommonEvent
.
subscribe
(
subscriber
,
s
ubscribeCallBack
);
}
}
//取消订阅公共事件回调
function
U
nsubscribeCallBack
(
err
)
{
function
u
nsubscribeCallBack
(
err
)
{
if
(
err
.
code
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -524,10 +524,10 @@ function UnsubscribeCallBack(err) {
}
//创建订阅者
CommonEvent
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEvent
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
//取消订阅公共事件
CommonEvent
.
unsubscribe
(
subscriber
,
U
nsubscribeCallBack
);
CommonEvent
.
unsubscribe
(
subscriber
,
u
nsubscribeCallBack
);
```
## CommonEventSubscriber
...
...
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md
浏览文件 @
461fd762
...
...
@@ -206,7 +206,7 @@ publish(event: string, callback: AsyncCallback\<void>): void
```
ts
//发布公共事件回调
function
P
ublishCallBack
(
err
)
{
function
p
ublishCallBack
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -216,7 +216,7 @@ function PublishCallBack(err) {
//发布公共事件
try
{
CommonEventManager
.
publish
(
"
event
"
,
P
ublishCallBack
);
CommonEventManager
.
publish
(
"
event
"
,
p
ublishCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
publish failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -259,7 +259,7 @@ var options = {
}
//发布公共事件回调
function
P
ublishCallBack
(
err
)
{
function
p
ublishCallBack
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publish failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -269,7 +269,7 @@ function PublishCallBack(err) {
//发布公共事件
try
{
CommonEventManager
.
publish
(
"
event
"
,
options
,
P
ublishCallBack
);
CommonEventManager
.
publish
(
"
event
"
,
options
,
p
ublishCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
publish failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -307,7 +307,7 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
```
ts
//发布公共事件回调
function
P
ublishAsUserCallBack
(
err
)
{
function
p
ublishAsUserCallBack
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -320,7 +320,7 @@ var userId = 100;
//发布公共事件
try
{
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
P
ublishAsUserCallBack
);
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
p
ublishAsUserCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
publishAsUser failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -366,7 +366,7 @@ var options = {
}
//发布公共事件回调
function
P
ublishAsUserCallBack
(
err
)
{
function
p
ublishAsUserCallBack
(
err
)
{
if
(
err
)
{
console
.
error
(
"
publishAsUser failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -379,7 +379,7 @@ var userId = 100;
//发布公共事件
try
{
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
options
,
P
ublishAsUserCallBack
);
CommonEventManager
.
publishAsUser
(
"
event
"
,
userId
,
options
,
p
ublishAsUserCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
publishAsUser failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -414,7 +414,7 @@ var subscribeInfo = {
};
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
!
err
)
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
...
...
@@ -425,7 +425,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
createSubscriber failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -514,7 +514,7 @@ function SubscribeCallBack(err, data) {
}
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
!
err
)
{
console
.
info
(
"
createSubscriber
"
);
subscriber
=
commonEventSubscriber
;
...
...
@@ -531,7 +531,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
}
catch
(
err
)
{
console
.
error
(
'
createSubscriber failed, catch error
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -563,7 +563,7 @@ var subscribeInfo = {
events
:
[
"
event
"
]
};
//订阅公共事件回调
function
S
ubscribeCallBack
(
err
,
data
)
{
function
s
ubscribeCallBack
(
err
,
data
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -571,7 +571,7 @@ function SubscribeCallBack(err, data) {
}
}
//创建订阅者回调
function
C
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
function
c
reateSubscriberCallBack
(
err
,
commonEventSubscriber
)
{
if
(
err
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -579,14 +579,14 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
subscriber
=
commonEventSubscriber
;
//订阅公共事件
try
{
CommonEventManager
.
subscribe
(
subscriber
,
S
ubscribeCallBack
);
CommonEventManager
.
subscribe
(
subscriber
,
s
ubscribeCallBack
);
}
catch
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
));
}
}
}
//取消订阅公共事件回调
function
U
nsubscribeCallBack
(
err
)
{
function
u
nsubscribeCallBack
(
err
)
{
if
(
err
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
else
{
...
...
@@ -595,14 +595,14 @@ function UnsubscribeCallBack(err) {
}
//创建订阅者
try
{
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
C
reateSubscriberCallBack
);
CommonEventManager
.
createSubscriber
(
subscribeInfo
,
c
reateSubscriberCallBack
);
}
catch
(
err
)
{
console
.
info
(
"
createSubscriber failed
"
+
JSON
.
stringify
(
err
));
}
//取消订阅公共事件
try
{
CommonEventManager
.
unsubscribe
(
subscriber
,
U
nsubscribeCallBack
);
CommonEventManager
.
unsubscribe
(
subscriber
,
u
nsubscribeCallBack
);
}
catch
(
err
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录