1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { AsyncCallback } from './../basic'; 16import { CommonEventSubscribeInfo } from './commonEventSubscribeInfo'; 17 18/** 19 * the subscriber of common event 20 * @name CommonEventSubscriber 21 * @since 7 22 * @permission N/A 23 */ 24export interface CommonEventSubscriber { 25 /** 26 * Obtains the result code of the current ordered common event. 27 * 28 * @since 7 29 * @param callback Indicate the callback funtion to receive the common event. 30 * @return - 31 */ 32 getCode(callback: AsyncCallback<number>): void; 33 34 /** 35 * Obtains the result code of the current ordered common event. 36 * 37 * @since 7 38 * @param callback Indicate the callback funtion to receive the common event. 39 * @return - 40 */ 41 getCode(): Promise<number>; 42 43 /** 44 * Sets the result code of the current ordered common event. 45 * 46 * @since 7 47 * @param code Indicates the custom result code to set. You can set it to any value. 48 * @param callback Indicate the callback funtion to receive the common event. 49 * @return - 50 */ 51 setCode(code: number, callback: AsyncCallback<void>): void; 52 53 /** 54 * Sets the result code of the current ordered common event. 55 * 56 * @since 7 57 * @param code Indicates the custom result code to set. You can set it to any value. 58 * @param callback Indicate the callback funtion to receive the common event. 59 * @return - 60 */ 61 setCode(code: number): Promise<void>; 62 63 /** 64 * Obtains the result data of the current ordered common event. 65 * 66 * @since 7 67 * @param callback Indicate the callback funtion to receive the common event. 68 * @return - 69 */ 70 getData(callback: AsyncCallback<string>): void; 71 72 /** 73 * Obtains the result data of the current ordered common event. 74 * 75 * @since 7 76 * @param callback Indicate the callback funtion to receive the common event. 77 * @return - 78 */ 79 getData(): Promise<string>; 80 81 /** 82 * Sets the result data of the current ordered common event. 83 * 84 * @since 7 85 * @param data Indicates the custom result data to set. You can set it to any character string. 86 * @param callback Indicate the callback funtion to receive the common event. 87 * @return - 88 */ 89 setData(data: string, callback: AsyncCallback<void>): void; 90 91 /** 92 * Sets the result data of the current ordered common event. 93 * 94 * @since 7 95 * @param data Indicates the custom result data to set. You can set it to any character string. 96 * @param callback Indicate the callback funtion to receive the common event. 97 * @return - 98 */ 99 setData(data: string): Promise<void>; 100 101 /** 102 * Sets the result of the current ordered common event. 103 * 104 * @since 7 105 * @param code Indicates the custom result code to set. You can set it to any value. 106 * @param data Indicates the custom result data to set. You can set it to any character string. 107 * @param callback Indicate the callback funtion to receive the common event. 108 * @return - 109 */ 110 setCodeAndData(code: number, data: string, callback: AsyncCallback<void>): void; 111 112 /** 113 * Sets the result of the current ordered common event. 114 * 115 * @since 7 116 * @param code Indicates the custom result code to set. You can set it to any value. 117 * @param data Indicates the custom result data to set. You can set it to any character string. 118 * @param callback Indicate the callback funtion to receive the common event. 119 * @return - 120 */ 121 setCodeAndData(code: number, data: string): Promise<void>; 122 123 /** 124 * Checks whether the current common event is an ordered common event. 125 * 126 * @since 7 127 * @param callback Indicate the callback funtion to receive the common event. 128 * @return - 129 */ 130 isOrderedCommonEvent(callback: AsyncCallback<boolean>): void; 131 132 /** 133 * Checks whether the current common event is an ordered common event. 134 * 135 * @since 7 136 * @param callback Indicate the callback funtion to receive the common event. 137 * @return - 138 */ 139 isOrderedCommonEvent(): Promise<boolean>; 140 141 /** 142 * Checks whether the current common event is a sticky common event. 143 * 144 * @since 7 145 * @param callback Indicate the callback funtion to receive the common event. 146 * @return - 147 */ 148 isStickyCommonEvent(callback: AsyncCallback<boolean>): void; 149 150 /** 151 * Checks whether the current common event is a sticky common event. 152 * 153 * @since 7 154 * @param callback Indicate the callback funtion to receive the common event. 155 * @return - 156 */ 157 isStickyCommonEvent(): Promise<boolean>; 158 159 /** 160 * Aborts the current ordered common event. 161 * 162 * @since 7 163 * @param callback Indicate the callback funtion to receive the common event. 164 * @return - 165 */ 166 abortCommonEvent(callback: AsyncCallback<void>): void; 167 168 /** 169 * Aborts the current ordered common event. 170 * 171 * @since 7 172 * @param callback Indicate the callback funtion to receive the common event. 173 * @return - 174 */ 175 abortCommonEvent(): Promise<void>; 176 177 /** 178 * Clears the abort state of the current ordered common event 179 * 180 * @since 7 181 * @param callback Indicate the callback funtion to receive the common event. 182 * @return - 183 */ 184 clearAbortCommonEvent(callback: AsyncCallback<void>): void; 185 186 /** 187 * Clears the abort state of the current ordered common event 188 * 189 * @since 7 190 * @param callback Indicate the callback funtion to receive the common event. 191 * @return - 192 */ 193 clearAbortCommonEvent(): Promise<void>; 194 195 /** 196 * Checks whether the current ordered common event should be aborted. 197 * 198 * @since 7 199 * @param callback Indicate the callback funtion to receive the common event. 200 * @return - 201 */ 202 getAbortCommonEvent(callback: AsyncCallback<boolean>): void; 203 204 /** 205 * Checks whether the current ordered common event should be aborted. 206 * 207 * @since 7 208 * @param callback Indicate the callback funtion to receive the common event. 209 * @return - 210 */ 211 getAbortCommonEvent(): Promise<boolean>; 212 213 /** 214 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 215 * 216 * @since 7 217 * @param callback Indicate the callback funtion to receive the common event. 218 * @return - 219 */ 220 getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void; 221 222 /** 223 * get the CommonEventSubscribeInfo of this CommonEventSubscriber. 224 * 225 * @since 7 226 * @param callback Indicate the callback funtion to receive the common event. 227 * @return - 228 */ 229 getSubscribeInfo(): Promise<CommonEventSubscribeInfo>; 230} 231