• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 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 */
15
16/**
17 * @file
18 * @kit BasicServicesKit
19 */
20
21/**
22 * Defines the basic callback.
23 * @typedef Callback
24 * @syscap SystemCapability.Base
25 * @since 6
26 */
27/**
28 * Defines the basic callback.
29 * @typedef Callback
30 * @syscap SystemCapability.Base
31 * @crossplatform
32 * @since 10
33 */
34/**
35 * Defines the basic callback.
36 * @typedef Callback
37 * @syscap SystemCapability.Base
38 * @crossplatform
39 * @atomicservice
40 * @since 11
41 */
42/**
43 * Defines the basic callback.
44 * @typedef Callback
45 * @syscap SystemCapability.Base
46 * @crossplatform
47 * @form
48 * @atomicservice
49 * @since 12
50 */
51export interface Callback<T> {
52  /**
53   * Defines the callback info.
54   * @param { T } data
55   * @syscap SystemCapability.Base
56   * @since 6
57   */
58  /**
59   * Defines the callback info.
60   * @param { T } data
61   * @syscap SystemCapability.Base
62   * @crossplatform
63   * @since 10
64   */
65  /**
66   * Defines the callback info.
67   * @param { T } data
68   * @syscap SystemCapability.Base
69   * @crossplatform
70   * @atomicservice
71   * @since 11
72   */
73  /**
74   * Defines the callback info.
75   * @param { T } data
76   * @syscap SystemCapability.Base
77   * @crossplatform
78   * @form
79   * @atomicservice
80   * @since 12
81   */
82  (data: T): void;
83}
84
85/**
86 * Defines the basic error callback.
87 * @typedef ErrorCallback
88 * @syscap SystemCapability.Base
89 * @since 6
90 */
91/**
92 * Defines the basic error callback.
93 * @typedef ErrorCallback
94 * @syscap SystemCapability.Base
95 * @crossplatform
96 * @since 10
97 */
98/**
99 * Defines the basic error callback.
100 * @typedef ErrorCallback
101 * @syscap SystemCapability.Base
102 * @crossplatform
103 * @atomicservice
104 * @since 11
105 */
106export interface ErrorCallback<T extends Error = BusinessError> {
107  /**
108   * Defines the basic error callback.
109   * @param { T } err
110   * @syscap SystemCapability.Base
111   * @since 6
112   */
113  /**
114   * Defines the basic error callback.
115   * @param { T } err
116   * @syscap SystemCapability.Base
117   * @crossplatform
118   * @since 10
119   */
120  /**
121   * Defines the basic error callback.
122   * @param { T } err
123   * @syscap SystemCapability.Base
124   * @crossplatform
125   * @atomicservice
126   * @since 11
127   */
128  (err: T): void;
129}
130
131/**
132 * Defines the basic async callback.
133 * @typedef AsyncCallback
134 * @syscap SystemCapability.Base
135 * @since 6
136 */
137/**
138 * Defines the basic async callback.
139 * @typedef AsyncCallback
140 * @syscap SystemCapability.Base
141 * @crossplatform
142 * @since 10
143 */
144/**
145 * Defines the basic async callback.
146 * @typedef AsyncCallback
147 * @syscap SystemCapability.Base
148 * @crossplatform
149 * @atomicservice
150 * @since 11
151 */
152/**
153 * Defines the basic async callback.
154 * @typedef AsyncCallback
155 * @syscap SystemCapability.Base
156 * @crossplatform
157 * @form
158 * @atomicservice
159 * @since 12
160 */
161export interface AsyncCallback<T, E = void> {
162  /**
163   * Defines the callback data.
164   * @param { BusinessError<E> } err
165   * @param { T } data
166   * @syscap SystemCapability.Base
167   * @since 6
168   */
169  /**
170   * Defines the callback data.
171   * @param { BusinessError<E> } err
172   * @param { T } data
173   * @syscap SystemCapability.Base
174   * @crossplatform
175   * @since 10
176   */
177  /**
178   * Defines the callback data.
179   * @param { BusinessError<E> } err
180   * @param { T } data
181   * @syscap SystemCapability.Base
182   * @crossplatform
183   * @atomicservice
184   * @since 11
185   */
186  /**
187   * Defines the callback data.
188   * @param { BusinessError<E> } err
189   * @param { T } data
190   * @syscap SystemCapability.Base
191   * @crossplatform
192   * @form
193   * @atomicservice
194   * @since 12
195   */
196  (err: BusinessError<E>, data: T): void;
197}
198
199/**
200 * Defines the error interface.
201 * @typedef BusinessError
202 * @syscap SystemCapability.Base
203 * @since 6
204 */
205/**
206 * Defines the error interface.
207 * @typedef BusinessError
208 * @syscap SystemCapability.Base
209 * @crossplatform
210 * @since 10
211 */
212/**
213 * Defines the error interface.
214 * @typedef BusinessError
215 * @syscap SystemCapability.Base
216 * @crossplatform
217 * @atomicservice
218 * @since 11
219 */
220/**
221 * Defines the error interface.
222 * @typedef BusinessError
223 * @syscap SystemCapability.Base
224 * @crossplatform
225 * @form
226 * @atomicservice
227 * @since 12
228 */
229export interface BusinessError<T = void> extends Error {
230  /**
231   * Defines the basic error code.
232   * @type { number } code
233   * @syscap SystemCapability.Base
234   * @since 6
235   */
236  /**
237   * Defines the basic error code.
238   * @type { number } code
239   * @syscap SystemCapability.Base
240   * @crossplatform
241   * @since 10
242   */
243  /**
244   * Defines the basic error code.
245   * @type { number } code
246   * @syscap SystemCapability.Base
247   * @crossplatform
248   * @atomicservice
249   * @since 11
250   */
251  /**
252   * Defines the basic error code.
253   * @type { number } code
254   * @syscap SystemCapability.Base
255   * @crossplatform
256   * @form
257   * @atomicservice
258   * @since 12
259   */
260  code: number;
261  /**
262   * Defines the additional information for business
263   * @type { ?T } data
264   * @syscap SystemCapability.Base
265   * @since 9
266   */
267  /**
268   * Defines the additional information for business
269   * @type { ?T } data
270   * @syscap SystemCapability.Base
271   * @crossplatform
272   * @since 10
273   */
274  /**
275   * Defines the additional information for business
276   * @type { ?T } data
277   * @syscap SystemCapability.Base
278   * @crossplatform
279   * @atomicservice
280   * @since 11
281   */
282  /**
283   * Defines the additional information for business
284   * @type { ?T } data
285   * @syscap SystemCapability.Base
286   * @crossplatform
287   * @form
288   * @atomicservice
289   * @since 12
290   */
291  data?: T;
292}
293