diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index 440ed7160c1736522027f42050d0affd1c98ad71..4ff96ed5e1b1427d87a35043d2ee53cb686c3698 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th | Class| API| Description| | -------- | -------- | -------- | | DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| -| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| +| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes.
**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| ### Observing Online or Offline Status @@ -93,7 +93,7 @@ The following example shows how to implement a distributed data object synchroni // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18. ``` -4. Observe the data changes of the distributed data object. You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes. +4. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes. The sample code is as follows: diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 9224a7ba33dfc51ca978a04b65e66e750d2110a1..afd07e6d85cd00e521fb230415e9f32cdd5d1fe3 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -32,14 +32,14 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -77,18 +77,18 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| - | name | string | Yes| Name of the** Preferences** instance persistence file.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[Preferences](#preferences)> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -126,14 +126,14 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -159,18 +159,18 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| - | name | string | Yes| Name of the** Preferences** instance persistence file.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -196,14 +196,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| - | name | string | Yes| Name of the** Preferences** instance persistence file.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -230,18 +230,18 @@ When a **Preferences** singleton instance is removed, this instance cannot be us **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| - | name | string | Yes| Name of the** Preferences** instance persistence file.| + | name | string | Yes| Name of the **Preferences** instance persistence file.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -270,14 +270,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to obtain. It cannot be empty.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| | callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -308,18 +308,18 @@ Obtains the value of a key. If the value is null or a non-default value, the def **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to obtain. It cannot be empty.| | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<ValueType> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -348,14 +348,14 @@ Puts a new value to this **Preferences** instance and its persistence file. This **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -386,18 +386,18 @@ Puts a new value to this **Preferences** instance and its persistence file. This **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data. It cannot be empty.| | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -426,18 +426,18 @@ Checks whether this **Preferences** instance contains data with a given key. Thi **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to check. It cannot be empty.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -472,17 +472,17 @@ Checks whether this **Preferences** instance contains data with a given key. Thi **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the data to check. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -515,13 +515,13 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the KV pair to delete. It cannot be empty.| | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -552,17 +552,17 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | key | string | Yes| Key of the KV pair to delete. It cannot be empty.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -591,12 +591,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -627,12 +627,12 @@ Saves the modification to this **Preferences** instance and synchronizes the mod **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -661,12 +661,12 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -697,12 +697,12 @@ Clears data of this **Preferences** instance. This API uses a promise to return **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -731,13 +731,13 @@ Subscribes to data changes. When the value of the subscribed key changes, a call **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Description| | -------- | -------- | -------- | | type | string | Event type. The value **change** indicates data change events.| | callback | Callback<{ key : string }> | Callback used to return data changes.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences' @@ -779,13 +779,13 @@ Unsubscribes from data changes. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -- Parameters +**Parameters** | Name| Type| Description| | -------- | -------- | -------- | | type | string | Event type. The value **change** indicates data change events.| | callback | Callback<{ key : string }> | Callback used to return data changes.| -- Example +**Example** ```ts import Ability from '@ohos.application.Ability' import data_preferences from '@ohos.data.preferences'