提交 03337111 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 6274f3a9
...@@ -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&lt;void&gt;): void off(event: 'distributedDataServiceDie', deathCallback?: Callback&lt;void&gt;): 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&lt;[ChangeNotification](#changenotification)&gt; | Yes |Callback used to return the data changes.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; | 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&lt;[ChangeNotification](#changenotification)&gt; |No |Callback used to return the data changes.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |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&lt;Array&lt;[string, number]&gt;&gt;): void off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&gt;&gt;): 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&lt;Array&lt;[string, number]&gt;&gt;): void on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): 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&lt;Array&lt;[string, number]&gt;&gt; | Yes |Callback called to return the synchronization result. | | syncCallback |Callback&lt;Array&lt;[string, number]&gt;&gt; | Yes |Callback used to return the synchronization result. |
**Example** **Example**
...@@ -4083,7 +4098,7 @@ try { ...@@ -4083,7 +4098,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 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&lt;ChangeNotification&gt;): void off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): 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&lt;Array&lt;[string, number]&gt;&gt;): void on(event: 'syncComplete', syncCallback: Callback&lt;Array&lt;[string, number]&gt;&gt;): 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&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 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&lt;[ChangeNotification](#changenotification)&gt; | Yes |Callback used to return the result.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; | 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&lt;ChangeNotification&gt;): void off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): 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&lt;[ChangeNotification](#changenotification)&gt; |No |Callback used to return the result.| | listener |Callback&lt;[ChangeNotification](#changenotification)&gt; |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.
先完成此消息的编辑!
想要评论请 注册