interface_sdk-js/api/commonEvent/commonEventSubscriber.d.ts
xinking129 0c2b749cad JSDoc change
Signed-off-by: xinking129 <xinxin13@huawei.com>
2023-05-06 14:59:50 +08:00

251 lines
8.6 KiB
TypeScript

/*
* Copyright (c) 2021-2023 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 } from './../@ohos.base';
import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo';
/**
* the subscriber of common event
*
* @interface CommonEventSubscriber
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
export interface CommonEventSubscriber {
/**
* Obtains the result code of the current ordered common event.
*
* @param { AsyncCallback<number> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getCode(callback: AsyncCallback<number>): void;
/**
* Obtains the result code of the current ordered common event.
*
* @returns { Promise<number> } Returns code of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getCode(): Promise<number>;
/**
* Sets the result code of the current ordered common event.
*
* @param { number } code Indicates the custom result code to set. You can set it to any value.
* @param { AsyncCallback<void> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setCode(code: number, callback: AsyncCallback<void>): void;
/**
* Sets the result code of the current ordered common event.
*
* @param { number } code Indicates the custom result code to set. You can set it to any value.
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setCode(code: number): Promise<void>;
/**
* Obtains the result data of the current ordered common event.
*
* @param { AsyncCallback<string> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getData(callback: AsyncCallback<string>): void;
/**
* Obtains the result data of the current ordered common event.
*
* @returns { Promise<string> } Returns data of this common event
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getData(): Promise<string>;
/**
* Sets the result data of the current ordered common event.
*
* @param { string } data Indicates the custom result data to set. You can set it to any character string.
* @param { AsyncCallback<void> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setData(data: string, callback: AsyncCallback<void>): void;
/**
* Sets the result data of the current ordered common event.
*
* @param { string } data Indicates the custom result data to set. You can set it to any character string.
* @returns { Promise<void> } the promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setData(data: string): Promise<void>;
/**
* Sets the result of the current ordered common event.
*
* @param { number } code Indicates the custom result code to set. You can set it to any value.
* @param { string } data Indicates the custom result data to set. You can set it to any character string.
* @param { AsyncCallback<void> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void;
/**
* Sets the result of the current ordered common event.
*
* @param { number } code Indicates the custom result code to set. You can set it to any value.
* @param { string } data Indicates the custom result data to set. You can set it to any character string.
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
setCodeAndData(code: number, data: string): Promise<void>;
/**
* Checks whether the current common event is an ordered common event.
*
* @param { AsyncCallback<boolean> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the current common event is an ordered common event.
*
* @returns { Promise<boolean> } Returns true if this common event is ordered, false otherwise
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
isOrderedCommonEvent(): Promise<boolean>;
/**
* Checks whether the current common event is a sticky common event.
*
* @param { AsyncCallback<boolean> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
isStickyCommonEvent(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the current common event is a sticky common event.
*
* @returns { Promise<boolean> } Returns true if this common event is sticky, false otherwise
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
isStickyCommonEvent(): Promise<boolean>;
/**
* Abort the current ordered common event.
*
* @param { AsyncCallback<void> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
abortCommonEvent(callback: AsyncCallback<void>): void;
/**
* Abort the current ordered common event.
*
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
abortCommonEvent(): Promise<void>;
/**
* Clears the abort state of the current ordered common event
*
* @param { AsyncCallback<void> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
clearAbortCommonEvent(callback: AsyncCallback<void>): void;
/**
* Clears the abort state of the current ordered common event
*
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
clearAbortCommonEvent(): Promise<void>;
/**
* Checks whether the current ordered common event should be aborted.
*
* @param { AsyncCallback<boolean> } callback Indicate the callback function to receive the common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getAbortCommonEvent(callback: AsyncCallback<boolean>): void;
/**
* Checks whether the current ordered common event should be aborted.
*
* @returns { Promise<boolean> } Returns true if this common event is aborted, false otherwise
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getAbortCommonEvent(): Promise<boolean>;
/**
* get the CommonEventSubscribeInfo of this CommonEventSubscriber.
*
* @param { AsyncCallback<CommonEventSubscribeInfo> } callback Indicate callback function to receive common event.
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void;
/**
* get the CommonEventSubscribeInfo of this CommonEventSubscriber.
*
* @returns { Promise<CommonEventSubscribeInfo> } Returns the commonEvent subscribe information
* @syscap SystemCapability.Notification.CommonEvent
* @since 7
*/
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>;
/**
* finish the current ordered common event.
*
* @param { AsyncCallback<void> } callback Indicate the callback function after ordered common event is finished.
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
finishCommonEvent(callback: AsyncCallback<void>): void;
/**
* finish the current ordered common event.
*
* @returns { Promise<void> } The promise returned by the function.
* @syscap SystemCapability.Notification.CommonEvent
* @since 9
*/
finishCommonEvent(): Promise<void>;
}