未验证 提交 7be99485 编写于 作者: O openharmony_ci 提交者: Gitee

!9582 [翻译完成】#I5NCZN

Merge pull request !9582 from Annie_wang/PR8351
...@@ -512,8 +512,8 @@ Subscribes to service status changes. ...@@ -512,8 +512,8 @@ Subscribes to service status changes.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event | string | Yes | Event to subscribe to. The value is **distributedDataServiceDie**, which indicates 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 service status changes.| | deathCallback | Callback<void> | Yes | Callback used to return a service status change event.|
**Example** **Example**
...@@ -536,7 +536,7 @@ try { ...@@ -536,7 +536,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
...@@ -544,8 +544,8 @@ Unsubscribes from the service status changes. ...@@ -544,8 +544,8 @@ Unsubscribes from the service status changes.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates 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 service status changes.| | deathCallback | Callback<void> | No | Callback for the service status change event.|
**Example** **Example**
...@@ -744,7 +744,7 @@ try { ...@@ -744,7 +744,7 @@ try {
console.log('getResultSet succeed.'); console.log('getResultSet succeed.');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet failed:' + err); console.log('getResultSet failed: ' + err);
}); });
const count = resultSet.getCount(); const count = resultSet.getCount();
console.log("getCount succeed:" + count); console.log("getCount succeed:" + count);
...@@ -777,7 +777,7 @@ try { ...@@ -777,7 +777,7 @@ try {
console.log('getResultSet succeeded.'); console.log('getResultSet succeeded.');
resultSet = result; resultSet = result;
}).catch((err) => { }).catch((err) => {
console.log('getResultSet failed:' + err); console.log('getResultSet failed: ' + err);
}); });
const position = resultSet.getPosition(); const position = resultSet.getPosition();
console.log("getPosition succeed:" + position); console.log("getPosition succeed:" + position);
...@@ -2232,7 +2232,7 @@ try { ...@@ -2232,7 +2232,7 @@ try {
on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
Subscribes to data change notifications of the specified type. Subscribes to data changes of the specified type.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2240,9 +2240,9 @@ Subscribes to data change notifications of the specified type. ...@@ -2240,9 +2240,9 @@ Subscribes to data change notifications of the specified type.
| Name | Type| Mandatory | Description | | 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 |Type of data changes. | | type |[SubscribeType](#subscribetype) | Yes |Type of data change. |
| observer |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return the data changes.| | observer |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return a data change event.|
**Example** **Example**
...@@ -2258,7 +2258,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun ...@@ -2258,7 +2258,7 @@ kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, fun
on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void 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 **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2266,8 +2266,8 @@ Subscribes to data synchronization complete events. ...@@ -2266,8 +2266,8 @@ Subscribes to 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 a synchronization complete event. |
| syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return the data synchronization result. | | syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return a synchronization complete event. |
**Example** **Example**
...@@ -2282,7 +2282,7 @@ kvStore.on('syncComplete', function (data) { ...@@ -2282,7 +2282,7 @@ kvStore.on('syncComplete', function (data) {
off(event:'dataChange', observer?: Callback<ChangeNotification>): void off(event:'dataChange', observer?: Callback<ChangeNotification>): void
Unsubscribes from data change notifications. Unsubscribes from data changes.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -2290,19 +2290,28 @@ Unsubscribes from data change notifications. ...@@ -2290,19 +2290,28 @@ 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 a data change event. |
| observer |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return the data changes.| | observer |Callback<[ChangeNotification](#changenotification)> |No |Callback for the service status change event.|
**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);
}
}
}
``` ```
...@@ -3708,7 +3717,7 @@ try { ...@@ -3708,7 +3717,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 synchronization complete events.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -3716,8 +3725,8 @@ Subscribes to the data synchronization complete events. ...@@ -3716,8 +3725,8 @@ 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 a synchronization complete event. |
| syncCallback |Callback<Array<[string, number]>> | Yes |Callback invoked to return the synchronization result. | | syncCallback |Callback<Array<[string, number]>> | Yes |Callback invoked to return a synchronization complete event. |
**Example** **Example**
...@@ -3744,7 +3753,7 @@ try { ...@@ -3744,7 +3753,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 synchronization complete events.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -3752,21 +3761,27 @@ Unsubscribes from the data synchronization complete events. ...@@ -3752,21 +3761,27 @@ Unsubscribes from the data synchronization complete events.
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates completion of a data synchronization. | | 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 the synchronization result. | | syncCallback |Callback<Array<[string, number]>> | No |Callback for the synchronization complete event. |
**Example** **Example**
```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);
}
}
} }
``` ```
...@@ -3785,7 +3800,7 @@ Synchronizes the KV store manually. For details about the synchronization modes ...@@ -3785,7 +3800,7 @@ Synchronizes the KV store manually. For details about the synchronization modes
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceIdList |string[] | Yes |IDs of the devices to be synchronized. These devices must be in the same networking environment. | | deviceIdList |string[] | Yes |IDs of the devices in the same networking environment to be synchronized.|
| mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | | mode |[SyncMode](#syncmode) | Yes |Synchronization mode. |
| allowedDelayMs |number | No |Allowed synchronization delay time, in ms. | | allowedDelayMs |number | No |Allowed synchronization delay time, in ms. |
...@@ -5067,7 +5082,7 @@ try { ...@@ -5067,7 +5082,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 synchronization complete events.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -5075,8 +5090,8 @@ Subscribes to the data synchronization complete events. ...@@ -5075,8 +5090,8 @@ 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 the data synchronization complete event.| | 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 used to return the synchronization result. | | syncCallback |Callback<Array&lt;[string, number]&gt;> | Yes |Callback invoked to return a synchronization complete event. |
**Example** **Example**
...@@ -5103,7 +5118,7 @@ try { ...@@ -5103,7 +5118,7 @@ try {
off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): void
Unsubscribes from the synchronization complete 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 **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -5111,21 +5126,27 @@ Unsubscribes from the synchronization complete events. This API uses a synchrono ...@@ -5111,21 +5126,27 @@ Unsubscribes from the synchronization complete events. This API uses a synchrono
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates the data synchronization complete event.| | event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.|
| syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | No |Callback used to return the synchronization result. | | syncCallback |Callback<Array&lt;[string, number]&gt;&gt; | No |Callback for the synchronization complete event. |
**Example** **Example**
```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);
}
}
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册