提交 5135c2a7 编写于 作者: Z zuojiangjiang

fix example code

Signed-off-by: Nzuojiangjiang <zuojiangjiang@huawei.com>
上级 0a67b570
...@@ -2447,13 +2447,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void ...@@ -2447,13 +2447,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
kvStore.on('dataChange', function (data) { kvmanager;
console.log("callback call data: " + data); kvStore;
});
kvStore.off('dataChange', function (data) { constructor() {}
console.log("callback call data: " + data); call(data) {
}); console.log("dataChange: " + data);
}
subscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_REMOTE, this.call);
}
}
unsubscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.off('dataChange', this.call);
}
}
}
``` ```
### off('syncComplete')<sup>9+</sup> ### off('syncComplete')<sup>9+</sup>
...@@ -2474,15 +2486,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]& ...@@ -2474,15 +2486,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
try { kvmanager;
const func = function (data) { kvStore;
console.log('syncComplete ' + data)
}; constructor() {}
kvStore.on('syncComplete', func); call(data) {
kvStore.off('syncComplete', func); console.log("syncComplete: " + data);
}catch(e) { }
console.log('syncComplete e ' + e); subscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.on('syncComplete', this.call);
}
}
unsubscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.off('syncComplete', this.call);
}
}
} }
``` ```
...@@ -4097,15 +4118,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]& ...@@ -4097,15 +4118,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
try { kvmanager;
const func = function (data) { kvStore;
console.log('syncComplete ' + data)
}; constructor() {}
kvStore.on('syncComplete', func); call(data) {
kvStore.off('syncComplete', func); console.log("syncComplete: " + data);
}catch(e) { }
console.log('syncComplete e ' + e); subscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.on('syncComplete', this.call);
}
}
unsubscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.off('syncComplete', this.call);
}
}
} }
``` ```
...@@ -4153,13 +4183,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void ...@@ -4153,13 +4183,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
kvStore.on('dataChange', function (data) { kvmanager;
console.log("callback call data: " + data); kvStore;
});
kvStore.off('dataChange', function (data) { constructor() {}
console.log("callback call data: " + data); call(data) {
}); console.log("dataChange: " + data);
}
subscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_REMOTE, this.call);
}
}
unsubscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.off('dataChange', this.call);
}
}
}
``` ```
### sync<sup>7+</sup> ### sync<sup>7+</sup>
...@@ -5592,15 +5634,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]& ...@@ -5592,15 +5634,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
try { kvmanager;
const func = function (data) { kvStore;
console.log('syncComplete ' + data)
}; constructor() {}
kvStore.on('syncComplete', func); call(data) {
kvStore.off('syncComplete', func); console.log("syncComplete: " + data);
}catch(e) { }
console.log('syncComplete e ' + e); subscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.on('syncComplete', this.call);
}
}
unsubscribeSyncComplete() {
if (this.kvStore != null) {
this.kvStore.off('syncComplete', this.call);
}
}
} }
``` ```
...@@ -5648,13 +5699,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void ...@@ -5648,13 +5699,25 @@ off(event:'dataChange', listener?: Callback&lt;ChangeNotification&gt;): void
**示例:** **示例:**
```js ```js
let kvStore; export class KvstoreModel {
kvStore.on('dataChange', function (data) { kvmanager;
console.log("callback call data: " + data); kvStore;
});
kvStore.off('dataChange', function (data) { constructor() {}
console.log("callback call data: " + data); call(data) {
}); console.log("dataChange: " + data);
}
subscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_REMOTE, this.call);
}
}
unsubscribeDataChange() {
if (this.kvStore != null) {
this.kvStore.off('dataChange', this.call);
}
}
}
``` ```
## SyncMode ## SyncMode
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册