Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
28cca7b0
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
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看板
未验证
提交
28cca7b0
编写于
9月 16, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
!9412 [翻译完成】#I5NCZG
Merge pull request !9412 from Annie_wang/PR8350
上级
58fc987b
df89a466
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
132 addition
and
88 deletion
+132
-88
en/application-dev/reference/apis/js-apis-distributed-data.md
...pplication-dev/reference/apis/js-apis-distributed-data.md
+132
-88
未找到文件。
en/application-dev/reference/apis/js-apis-distributed-data.md
浏览文件 @
28cca7b0
...
...
@@ -61,7 +61,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
});
}
...
...
@@ -89,7 +89,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
});
}
...
...
@@ -139,7 +139,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
});
}
...
...
@@ -167,7 +167,7 @@ export default class MyAbilityStage extends AbilityStage {
console
.
log
(
"
Failed to create KVManager:
"
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
"
Created KVManager
"
);
console
.
log
(
"
Created KVManager
successfully
"
);
kvManager
=
manager
;
});
}
...
...
@@ -582,8 +582,8 @@ Subscribes to service status changes.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event | string | Yes | Event to subscribe to. The value is
**distributedDataServiceDie**
, which indicates
service status changes
.|
| deathCallback | Callback
<
void
>
| Yes | Callback invoked to return
service status changes
.|
| event | string | Yes | Event to subscribe to. The value is
**distributedDataServiceDie**
, which indicates
a service status change event
.|
| deathCallback | Callback
<
void
>
| Yes | Callback invoked to return
a service status change event
.|
**Example**
...
...
@@ -606,7 +606,7 @@ try {
off(event: 'distributedDataServiceDie', deathCallback?: Callback
<
void
>
): void
Unsubscribes from
the
service status changes.
Unsubscribes from service status changes.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore
...
...
@@ -614,8 +614,8 @@ Unsubscribes from the service status changes.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event | string | Yes | Event to unsubscribe from. The value is
**distributedDataServiceDie**
, which indicates
service status changes
.|
| deathCallback | Callback
<
void
>
| No | Callback used to return
service status changes
.|
| event | string | Yes | Event to unsubscribe from. The value is
**distributedDataServiceDie**
, which indicates
a service status change event
.|
| deathCallback | Callback
<
void
>
| No | Callback used to return
a service status change event
.|
**Example**
...
...
@@ -2383,7 +2383,7 @@ try {
on(event: 'dataChange', type: SubscribeType, listener: Callback
<
ChangeNotification
>
): void
Subscribes to data change
notification
s of the specified type.
Subscribes to data changes of the specified type.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -2391,9 +2391,9 @@ Subscribes to data change notifications of the specified type.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates
data changes
. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Type of data change
s
. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback
used to return the data changes
.|
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates
a data change event
. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Type of data change. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback
invoked to return a data change event
.|
**Example**
...
...
@@ -2409,7 +2409,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
Subscribes to
data
synchronization complete events.
Subscribes to synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -2417,8 +2417,8 @@ Subscribes to data synchronization complete events.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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
used to return the data synchronization resul
t. |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates
a synchronization complete event
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| Yes |Callback
invoked to return the a synchronization complete even
t. |
**Example**
...
...
@@ -2433,7 +2433,7 @@ kvStore.on('syncComplete', function (data) {
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
Unsubscribes from data change
notification
s.
Unsubscribes from data changes.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -2441,26 +2441,35 @@ Unsubscribes from data change notifications.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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
.|
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates
a data change event
. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
a data change event
.|
**Example**
```
js
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
dataChange:
"
+
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(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
synchronization complete events. This API returns the result synchronously
.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -2468,21 +2477,27 @@ Unsubscribes from data change events. This API uses a synchronous callback to re
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates
completion of a data synchronization
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| No |Callback used to return
the synchronization resul
t. |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates
a synchronization complete event
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| No |Callback used to return
a synchronization complete even
t. |
**Example**
```
js
let
kvStore
;
try
{
const
func
=
function
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
};
kvStore
.
on
(
'
syncComplete
'
,
func
);
kvStore
.
off
(
'
syncComplete
'
,
func
);
}
catch
(
e
)
{
console
.
log
(
'
syncComplete e
'
+
e
);
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
syncComplete:
"
+
data
);
}
subscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
```
...
...
@@ -4047,7 +4062,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
Subscribes to
the data
synchronization complete events.
Subscribes to synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -4055,8 +4070,8 @@ Subscribes to the data synchronization complete events.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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
called to return the synchronization resul
t. |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates
a synchronization complete event
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| Yes |Callback
invoked to return a synchronization complete even
t. |
**Example**
...
...
@@ -4083,7 +4098,7 @@ try {
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
...
...
@@ -4091,21 +4106,27 @@ Unsubscribes from the data synchronization complete events.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates
completion of a data synchronization
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| No |Callback used to return
the synchronization resul
t. |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates
a synchronization complete event
. |
| syncCallback |Callback
<
Array
<
[string, number]
>>
| No |Callback used to return
a data synchronization complete even
t. |
**Example**
```
js
let
kvStore
;
try
{
const
func
=
function
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
};
kvStore
.
on
(
'
syncComplete
'
,
func
);
kvStore
.
off
(
'
syncComplete
'
,
func
);
}
catch
(
e
)
{
console
.
log
(
'
syncComplete e
'
+
e
);
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
syncComplete:
"
+
data
);
}
subscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
```
...
...
@@ -4121,9 +4142,9 @@ Subscribes to data changes of the specified type. This API returns the result sy
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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
a data change event
. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |Subscription type. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
the resul
t.|
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
a data change even
t.|
**Example**
...
...
@@ -4139,7 +4160,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
Unsubscribes from
the data change event
s. This API returns the result synchronously.
Unsubscribes from
data change
s. This API returns the result synchronously.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -4147,19 +4168,28 @@ Unsubscribes from the data change events. This API returns the result synchronou
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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 resul
t.|
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates
a data change event
. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
a data change even
t.|
**Example**
```
js
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
dataChange:
"
+
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>
...
...
@@ -5542,7 +5572,7 @@ try {
on(event: 'syncComplete', syncCallback: Callback
<
Array
<
[string, number]
>>
): void
Subscribes to
the data
synchronization complete events.
Subscribes to synchronization complete events.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -5550,8 +5580,8 @@ Subscribes to the data synchronization complete events.
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates
the dat
a synchronization complete event.|
| syncCallback |Callback
<Array
&
lt
;[
string
,
number
]&
gt
;
>
| Yes |Callback
used to return the synchronization resul
t. |
| event |string | Yes |Event to subscribe to. The value is
**syncComplete**
, which indicates a synchronization complete event.|
| syncCallback |Callback
<Array
&
lt
;[
string
,
number
]&
gt
;
>
| Yes |Callback
invoked to return a synchronization complete even
t. |
**Example**
...
...
@@ -5578,7 +5608,7 @@ try {
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
...
...
@@ -5586,21 +5616,27 @@ Unsubscribes from the synchronization complete events. This API returns the resu
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates the
dat
a synchronization complete event.|
| syncCallback |Callback<Array
<
[string, number]
>>
| No |Callback used to return
the synchronization resul
t. |
| event |string | Yes |Event to unsubscribe from. The value is
**syncComplete**
, which indicates the a synchronization complete event.|
| syncCallback |Callback<Array
<
[string, number]
>>
| No |Callback used to return
a synchronization complete even
t. |
**Example**
```
js
let
kvStore
;
try
{
const
func
=
function
(
data
)
{
console
.
log
(
'
syncComplete
'
+
data
)
};
kvStore
.
on
(
'
syncComplete
'
,
func
);
kvStore
.
off
(
'
syncComplete
'
,
func
);
}
catch
(
e
)
{
console
.
log
(
'
syncComplete e
'
+
e
);
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
syncComplete:
"
+
data
);
}
subscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
on
(
'
syncComplete
'
,
this
.
call
);
}
}
unsubscribeSyncComplete
()
{
if
(
kvStore
!=
null
)
{
kvStore
.
off
(
'
syncComplete
'
,
this
.
call
);
}
}
}
```
...
...
@@ -5616,9 +5652,9 @@ Subscribes to data changes of the specified type. This API returns the result sy
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates
data changes
. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |
Subscription typ
e. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
the resul
t.|
| event |string | Yes |Event to subscribe to. The value is
**dataChange**
, which indicates
a data change event
. |
| type |
[
SubscribeType
](
#subscribetype
)
| Yes |
Type of data chang
e. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
| Yes |Callback used to return
a data change even
t.|
**Example**
...
...
@@ -5634,7 +5670,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
off(event:'dataChange', listener?: Callback
<
ChangeNotification
>
): void
Unsubscribes from
the data change event
s. This API returns the result synchronously.
Unsubscribes from
data change
s. This API returns the result synchronously.
**System capability**
: SystemCapability.DistributedDataManager.KVStore.Core
...
...
@@ -5642,19 +5678,28 @@ Unsubscribes from the data change events. This API returns the result synchronou
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| 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 resul
t.|
| event |string | Yes |Event to unsubscribe from. The value is
**dataChange**
, which indicates
a data change event
. |
| listener |Callback
<
[ChangeNotification](#changenotification)
>
|No |Callback used to return
a data change even
t.|
**Example**
```
js
let
kvStore
;
kvStore
.
on
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
kvStore
.
off
(
'
dataChange
'
,
function
(
data
)
{
console
.
log
(
"
callback call data:
"
+
data
);
});
class
KvstoreModel
{
call
(
data
)
{
console
.
log
(
"
dataChange:
"
+
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
...
...
@@ -5668,4 +5713,3 @@ Enumerates the synchronization modes.
| 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_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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录