@@ -107,7 +107,9 @@ The following example shows how to implement a distributed data object synchroni
...
@@ -107,7 +107,9 @@ The following example shows how to implement a distributed data object synchroni
});
});
}
}
}
}
local_object.on("change",this.changeCallback);
// To refresh the page in changeCallback, correctly set this.changeCallback.bind(this) in
changeCallback.
```
```
5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
...
@@ -158,9 +160,9 @@ The following example shows how to implement a distributed data object synchroni
...
@@ -158,9 +160,9 @@ The following example shows how to implement a distributed data object synchroni
The sample code is as follows:
The sample code is as follows:
```js
```js
// Unsubscribe from statusCallback.
// Unsubscribe from the online status change callback.
local_object.off("status",statusCallback);
local_object.off("status",statusCallback);
// unsubscribe from all status change callbacks.
// Unsubscribe from all online status change callbacks.
local_object.off("status");
local_object.off("status");
```
```
10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end.
10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end.
...
@@ -169,7 +171,12 @@ The following example shows how to implement a distributed data object synchroni
...
@@ -169,7 +171,12 @@ The following example shows how to implement a distributed data object synchroni
```js
```js
local_object.setSessionId("");
local_object.setSessionId("");
```
```
## Development Example
The following example is provided for you to better understand the development of distributed data object:
When an event occurs on a device, for example, a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network by the Notepad app.
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.
## Modules to Import
## Modules to Import
...
@@ -15,7 +15,7 @@ import storagestatistics from "@ohos.storageStatistics";
...
@@ -15,7 +15,7 @@ import storagestatistics from "@ohos.storageStatistics";
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 9.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.