• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
15
16/**
17 * Defines the basic callback.
18 * @since 6
19 */
20export interface Callback<T> {
21  /**
22   * Defines the callback info.
23   * @since 6
24   */
25  (data: T): void;
26}
27
28/**
29 * Defines the basic error callback.
30 * @since 6
31 */
32export interface ErrorCallback<T extends Error = BusinessError> {
33  /**
34   * Defines the basic error callback.
35   * @since 6
36   */
37  (err: T): void;
38}
39
40/**
41 * Defines the basic async callback.
42 * @since 6
43 */
44export interface AsyncCallback<T, E = void> {
45  /**
46   * Defines the callback data.
47   * @since 6
48   */
49  (err: BusinessError<E>, data: T): void;
50}
51
52/**
53 * Defines the error interface.
54 * @since 6
55 */
56export interface BusinessError<T = void> extends Error {
57  /**
58   * Defines the basic error code.
59   * @since 6
60   */
61  code: number;
62  /**
63   * Defines the additional information for business
64   * @type { ?T }
65   * @since 9
66   */
67  data?: T;
68}
69