提交 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
**示例:**
```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);
});
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
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>
......@@ -2474,15 +2486,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
**示例:**
```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);
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
call(data) {
console.log("syncComplete: " + data);
}
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]&
**示例:**
```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);
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
call(data) {
console.log("syncComplete: " + data);
}
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
**示例:**
```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);
});
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
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>
......@@ -5592,15 +5634,24 @@ off(event: 'syncComplete', syncCallback?: Callback&lt;Array&lt;[string, number]&
**示例:**
```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);
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
call(data) {
console.log("syncComplete: " + data);
}
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
**示例:**
```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);
});
export class KvstoreModel {
kvmanager;
kvStore;
constructor() {}
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册