From c0fb7bc26ca1941007b071d3f0a0ccbb881732a8 Mon Sep 17 00:00:00 2001 From: hanlu Date: Mon, 17 Jan 2022 20:06:38 +0800 Subject: [PATCH 1/2] objectstore Signed-off-by: hanlu --- api/@ohos.data.distributedDataObject.d.ts | 78 +++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 api/@ohos.data.distributedDataObject.d.ts diff --git a/api/@ohos.data.distributedDataObject.d.ts b/api/@ohos.data.distributedDataObject.d.ts new file mode 100644 index 0000000000..5f0fadb773 --- /dev/null +++ b/api/@ohos.data.distributedDataObject.d.ts @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import {AsyncCallback, Callback} from './basic'; + +/** + * Provides interfaces to sync distributed object + * + * @name distributedDataObject + * @since 8 + * @sysCap + * @devices phone + */ +declare namespace distributedDataObject { + /** + * Create distributed data + * + * @param obj Init data of distributed data + * @return Returns the distributed object + * @since 8 + */ + function distributed(obj: object): DistributedObject; + + /** + * Generate a random sessionId + * + * @return Returns the random sessionId + * @since 8 + */ + function genSessionId(): string; + + /** + * Object create by {@link distributed}. + * + * @Syscap SystemCapability.Data.DATA_DISTRIBUTEDDATAMGR + * @devices phone + * @since 8 + */ + interface DistributedObject { + /** + * Change object session + * + * @param sessionId The sessionId to be joined, if empty, leave all session + * @return Operation result, true is success, false is failed + * @since 8 + */ + setSession(sessionId?: string): boolean; + + /** + * On watch of change + * + * @param callback The callback of change + * @since 8 + */ + on(type: 'change', callback: Callback<{ sessionId: string, fields: Array }>): void; + + /** + * Off watch of change + * + * @param callback If not null, off the callback, if undefined, off all callbacks + * @since 8 + */ + off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array }>): void; + } +} + +export default distributedDataObject; -- Gitee From c426d8bd2a5984d1982b85f63f61f35a421457f5 Mon Sep 17 00:00:00 2001 From: hanlu Date: Tue, 18 Jan 2022 20:38:13 +0800 Subject: [PATCH 2/2] objectstore Signed-off-by: hanlu --- api/@ohos.data.distributedDataObject.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/@ohos.data.distributedDataObject.d.ts b/api/@ohos.data.distributedDataObject.d.ts index 5f0fadb773..aa7f594fc7 100644 --- a/api/@ohos.data.distributedDataObject.d.ts +++ b/api/@ohos.data.distributedDataObject.d.ts @@ -24,13 +24,13 @@ import {AsyncCallback, Callback} from './basic'; */ declare namespace distributedDataObject { /** - * Create distributed data + * Create distributed object * - * @param obj Init data of distributed data + * @param source Init data of distributed object * @return Returns the distributed object * @since 8 */ - function distributed(obj: object): DistributedObject; + function createDistributedObject(source: object): DistributedObject; /** * Generate a random sessionId @@ -41,7 +41,7 @@ declare namespace distributedDataObject { function genSessionId(): string; /** - * Object create by {@link distributed}. + * Object create by {@link createDistributedObject}. * * @Syscap SystemCapability.Data.DATA_DISTRIBUTEDDATAMGR * @devices phone @@ -55,7 +55,7 @@ declare namespace distributedDataObject { * @return Operation result, true is success, false is failed * @since 8 */ - setSession(sessionId?: string): boolean; + setSessionId(sessionId?: string): boolean; /** * On watch of change -- Gitee