提交 17c859c0 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 e17ad863
......@@ -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&lt;string&gt; }>): void | Subscribes to data changes.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): 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&lt;string&gt; }>): void | Unsubscribes from data changes. <br>**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:
......
......@@ -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&lt;[Preferences](#preferences)&gt; | 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&lt;[Preferences](#preferences)&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;ValueType&gt; | 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&lt;ValueType&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;boolean&gt; | 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&lt;boolean&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | 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&lt;{ key : string }&gt; | 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&lt;{ key : string }&gt; | Callback used to return data changes.|
- Example
**Example**
```ts
import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册