Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
03337111
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看板
提交
03337111
编写于
9月 13, 2022
作者:
A
Annie_wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
Annie_wang
<
annie.wangli@huawei.com
>
上级
6274f3a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
104 addition
and
60 deletion
+104
-60
en/application-dev/reference/apis/js-apis-distributed-data.md
...pplication-dev/reference/apis/js-apis-distributed-data.md
+104
-60
未找到文件。
en/application-dev/reference/apis/js-apis-distributed-data.md
浏览文件 @
03337111
...
@@ -61,7 +61,7 @@ export default class MyAbilityStage extends AbilityStage {
...
@@ -61,7 +61,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
kvManager
=
manager
;
});
});
}
}
...
@@ -89,7 +89,7 @@ export default class MyAbilityStage extends AbilityStage {
...
@@ -89,7 +89,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
kvManager
=
manager
;
});
});
}
}
...
@@ -139,7 +139,7 @@ export default class MyAbilityStage extends AbilityStage {
...
@@ -139,7 +139,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
kvManager
=
manager
;
});
});
}
}
...
@@ -167,7 +167,7 @@ export default class MyAbilityStage extends AbilityStage {
...
@@ -167,7 +167,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
kvManager
=
manager
;
});
});
}
}
...
@@ -606,7 +606,7 @@ try {
...
@@ -606,7 +606,7 @@ try {
off(event: 'distributedDataServiceDie', deathCallback?: Callback
<
void
>
): void
off(event: 'distributedDataServiceDie', deathCallback?: Callback
<
void
>
): void
Unsubscribes from
the
service status changes.
Unsubscribes from service status changes.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
**System capability**
: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...
@@ -2393,7 +2393,7 @@ Subscribes to data change notifications of the specified type.
...
@@ -2393,7 +2393,7 @@ Subscribes to data change notifications of the specified type.
| ----- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates data changes. |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates data changes. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Type of data changes. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Type of data changes. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
the
data changes.|
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return data changes.|
**Example**
**Example**
...
@@ -2442,25 +2442,34 @@ Unsubscribes from data change notifications.
...
@@ -2442,25 +2442,34 @@ Unsubscribes from data change notifications.
| Name | Type| Mandatory | Description |
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates data changes. |
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates data changes. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
the
data changes.|
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return data changes.|
**Example**
**Example**
```
js
```
js
let
kvStore
;
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
class
KvstoreModel
{
console
.
log
(
"
callback call data:
"
+
data
);
call
(
data
)
{
});
console
.
log
(
"
dataChange:
"
+
data
);
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
}
console
.
log
(
"
callback call data:
"
+
data
);
subscribeDataChange
()
{
});
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
dataChange
'
,
distributedData
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
this
.
call
);
}
}
unsubscribeDataChange
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
dataChange
'
,
this
.
call
);
}
}
}
```
```
### off('syncComplete')<sup>9+</sup>
### off('syncComplete')<sup>9+</sup>
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
Unsubscribes from data change events. This API
uses a synchronous callback to return the result
.
Unsubscribes from data change events. This API
returns the result synchronously
.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -2475,14 +2484,20 @@ Unsubscribes from data change events. This API uses a synchronous callback to re
...
@@ -2475,14 +2484,20 @@ Unsubscribes from data change events. This API uses a synchronous callback to re
```
js
```
js
let
kvStore
;
let
kvStore
;
try
{
class
KvstoreModel
{
const
func
=
function
(
data
)
{
call
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
console
.
log
(
"
syncComplete:
"
+
data
);
};
}
kvStore
.
on
(
'
syncComplete
'
,
func
);
subscribeSyncComplete
()
{
kvStore
.
off
(
'
syncComplete
'
,
func
);
if
(
kvStore
!=
null
)
{
}
catch
(
e
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
console
.
log
(
'
syncComplete e
'
+
e
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
}
```
```
...
@@ -4047,7 +4062,7 @@ try {
...
@@ -4047,7 +4062,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
Subscribes to
the
data synchronization complete events.
Subscribes to data synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -4056,7 +4071,7 @@ Subscribes to the data synchronization complete events.
...
@@ -4056,7 +4071,7 @@ Subscribes to the data synchronization complete events.
| Name | Type| Mandatory | Description |
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates completion of a data synchronization. |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates completion of a data synchronization. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| Yes |Callback
call
ed to return the synchronization result. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| Yes |Callback
us
ed to return the synchronization result. |
**Example**
**Example**
...
@@ -4083,7 +4098,7 @@ try {
...
@@ -4083,7 +4098,7 @@ try {
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
Unsubscribes from
the
data synchronization complete events.
Unsubscribes from data synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -4098,14 +4113,20 @@ Unsubscribes from the data synchronization complete events.
...
@@ -4098,14 +4113,20 @@ Unsubscribes from the data synchronization complete events.
```
js
```
js
let
kvStore
;
let
kvStore
;
try
{
class
KvstoreModel
{
const
func
=
function
(
data
)
{
call
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
console
.
log
(
"
syncComplete:
"
+
data
);
};
}
kvStore
.
on
(
'
syncComplete
'
,
func
);
subscribeSyncComplete
()
{
kvStore
.
off
(
'
syncComplete
'
,
func
);
if
(
kvStore
!=
null
)
{
}
catch
(
e
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
console
.
log
(
'
syncComplete e
'
+
e
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
}
```
```
...
@@ -4139,7 +4160,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
...
@@ -4139,7 +4160,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
Unsubscribes from
the
data change events. This API returns the result synchronously.
Unsubscribes from data change events. This API returns the result synchronously.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -4154,12 +4175,21 @@ Unsubscribes from the data change events. This API returns the result synchronou
...
@@ -4154,12 +4175,21 @@ Unsubscribes from the data change events. This API returns the result synchronou
```
js
```
js
let
kvStore
;
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
class
KvstoreModel
{
console
.
log
(
"
callback call data:
"
+
data
);
call
(
data
)
{
});
console
.
log
(
"
dataChange:
"
+
data
);
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
}
console
.
log
(
"
callback call data:
"
+
data
);
subscribeDataChange
()
{
});
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
dataChange
'
,
distributedData
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
this
.
call
);
}
}
unsubscribeDataChange
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
dataChange
'
,
this
.
call
);
}
}
}
```
```
### sync<sup>7+</sup>
### sync<sup>7+</sup>
...
@@ -5542,7 +5572,7 @@ try {
...
@@ -5542,7 +5572,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
Subscribes to
the
data synchronization complete events.
Subscribes to data synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -5578,7 +5608,7 @@ try {
...
@@ -5578,7 +5608,7 @@ try {
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
off(event: 'syncComplete', syncCallback?: Callback
<
Array
<
[string, number]
>>
): void
Unsubscribes from
the
synchronization complete events. This API returns the result synchronously.
Unsubscribes from synchronization complete events. This API returns the result synchronously.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -5593,14 +5623,20 @@ Unsubscribes from the synchronization complete events. This API returns the resu
...
@@ -5593,14 +5623,20 @@ Unsubscribes from the synchronization complete events. This API returns the resu
```
js
```
js
let
kvStore
;
let
kvStore
;
try
{
class
KvstoreModel
{
const
func
=
function
(
data
)
{
call
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
console
.
log
(
"
syncComplete:
"
+
data
);
};
}
kvStore
.
on
(
'
syncComplete
'
,
func
);
subscribeSyncComplete
()
{
kvStore
.
off
(
'
syncComplete
'
,
func
);
if
(
kvStore
!=
null
)
{
}
catch
(
e
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
console
.
log
(
'
syncComplete e
'
+
e
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
}
```
```
...
@@ -5618,7 +5654,7 @@ Subscribes to data changes of the specified type. This API returns the result sy
...
@@ -5618,7 +5654,7 @@ Subscribes to data changes of the specified type. This API returns the result sy
| ----- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates data changes. |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates data changes. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Subscription type. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Subscription type. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
the result
.|
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
data changes
.|
**Example**
**Example**
...
@@ -5634,7 +5670,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
...
@@ -5634,7 +5670,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
Unsubscribes from
the
data change events. This API returns the result synchronously.
Unsubscribes from data change events. This API returns the result synchronously.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
@@ -5643,18 +5679,27 @@ Unsubscribes from the data change events. This API returns the result synchronou
...
@@ -5643,18 +5679,27 @@ Unsubscribes from the data change events. This API returns the result synchronou
| Name | Type| Mandatory | Description |
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates data changes. |
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates data changes. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
the result
.|
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
data changes
.|
**Example**
**Example**
```
js
```
js
let
kvStore
;
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
class
KvstoreModel
{
console
.
log
(
"
callback call data:
"
+
data
);
call
(
data
)
{
});
console
.
log
(
"
dataChange:
"
+
data
);
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
}
console
.
log
(
"
callback call data:
"
+
data
);
subscribeDataChange
()
{
});
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
dataChange
'
,
distributedData
.
SubscribeType
.
SUBSCRIBE_TYPE_REMOTE
,
this
.
call
);
}
}
unsubscribeDataChange
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
dataChange
'
,
this
.
call
);
}
}
}
```
```
## SyncMode
## SyncMode
...
@@ -5668,4 +5713,3 @@ Enumerates the synchronization modes.
...
@@ -5668,4 +5713,3 @@ Enumerates the synchronization modes.
| PULL_ONLY |0 |Pull data from the peer end to the local end only.|
| PULL_ONLY |0 |Pull data from the peer end to the local end only.|
| PUSH_ONLY |1 |Push data from the local end to the peer end only.|
| PUSH_ONLY |1 |Push data from the local end to the peer end only.|
| PUSH_PULL |2 |Push data from the local end to the peer end and then pull data from the peer end to the local end.|
| PUSH_PULL |2 |Push data from the local end to the peer end and then pull data from the peer end to the local end.|
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录