1# @ohos.base (Public Callback Information)
2
3The **Base** module defines the public callback types of ArkTS APIs, including the common and error callbacks.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - Since API version 12, the APIs of this module are supported in ArkTS widgets.
10
11## Modules to Import
12
13```
14import base from '@ohos.base';
15```
16
17## Callback
18
19Callback\<T> {
20
21(data: T): void;
22
23}
24
25Defines a common callback.
26
27You can set **data** to customize the data type of the information returned by the callback.
28
29**Atomic service API**: This API can be used in atomic services since API version 11.
30
31**System capability**: SystemCapability.Base
32
33| Name| Type| Mandatory| Description                      |
34| ---- | ---- | ---- | -------------------------- |
35| data | T    | Yes  | Common callback information.|
36
37## ErrorCallback
38
39ErrorCallback\<T extends Error = BusinessError> {
40
41(err: T): void;
42
43}
44
45Defines a common callback that carries an error parameter.
46
47The information returned by the callback is of the [BusinessError](#businesserror) type.
48
49**Atomic service API**: This API can be used in atomic services since API version 11.
50
51**System capability**: SystemCapability.Base
52
53**Parameters**
54
55| Name| Type| Mandatory| Description                        |
56| ---- | ---- | ---- | ---------------------------- |
57| err  | T    | Yes  | Common error information about the API invoking failure.|
58
59## AsyncCallback
60
61AsyncCallback\<T, E = void> {
62
63(err: BusinessError\<E>, data: T): void;
64
65}
66
67Defines a common callback that carries an error parameter and asynchronous return value.
68
69The error parameter is of the [BusinessError](#businesserror) type.
70
71The type of the asynchronous return value is defined by the developer.
72
73**Atomic service API**: This API can be used in atomic services since API version 11.
74
75**System capability**: SystemCapability.Base
76
77| Name| Type                                                        | Mandatory| Description                        |
78| ---- | ------------------------------------------------------------ | ---- | ---------------------------- |
79| err  | [BusinessError](#businesserror) | Yes  | Common error information about the API invoking failure.|
80| data | T                                                            | Yes  | Common callback information.  |
81
82## BusinessError
83
84BusinessError\<T = void> extends Error {
85
86code: number;
87
88data?: T;
89}
90
91Defines the error parameter.
92
93**Atomic service API**: This API can be used in atomic services since API version 11.
94
95**System capability**: SystemCapability.Base
96
97| Name| Type  | Mandatory| Description                                                      |
98| ---- | ------ | ---- | ---------------------------------------------------------- |
99| code | number | Yes  | Common error information about the API invoking failure.                            |
100| data | T      | No  | Common callback information. If this parameter is left empty, no related information is returned.|
101