add event hub crossplatform label

Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
xinking129 2024-02-22 09:40:40 +08:00
parent c1c1ede5d2
commit 1801811b73
3 changed files with 67 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -259,6 +259,15 @@ declare namespace common {
* @atomicservice
* @since 11
*/
/**
* The event center of a context, support the subscription and publication of events.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
export type EventHub = _EventHub.default;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -332,6 +332,16 @@ export default class Context extends BaseContext {
* @atomicservice
* @since 11
*/
/**
* Indicates event hub.
*
* @type { EventHub }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
eventHub: EventHub;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -30,6 +30,15 @@ import { BusinessError } from '../@ohos.base';
* @atomicservice
* @since 11
*/
/**
* The event center of a context, support the subscription and publication of events.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
export default class EventHub {
/**
* Subscribe to an event.
@ -52,6 +61,18 @@ export default class EventHub {
* @atomicservice
* @since 11
*/
/**
* Subscribe to an event.
*
* @param { string } event - Indicates the event.
* @param { Function } callback - Indicates the callback.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
on(event: string, callback: Function): void;
/**
@ -75,6 +96,18 @@ export default class EventHub {
* @atomicservice
* @since 11
*/
/**
* Unsubscribe from an event.
*
* @param { string } event - Indicates the event.
* @param { Function } [callback] - Indicates the callback.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
off(event: string, callback?: Function): void;
/**
@ -98,5 +131,17 @@ export default class EventHub {
* @atomicservice
* @since 11
*/
/**
* Trigger the event callbacks.
*
* @param { string } event - Indicates the event.
* @param { Object[] } args - Indicates the callback arguments.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @crossplatform
* @atomicservice
* @since 12
*/
emit(event: string, ...args: Object[]): void;
}