• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 Defines a modifier which can update attributes to native side.
18 * @kit ArkUI
19 */
20
21/**
22 * function that returns a default param of AttributeUpdater.
23 *
24 * @typedef { function } Initializer<T>
25 * @returns { T }
26 * @syscap SystemCapability.ArkUI.ArkUI.Full
27 * @crossplatform
28 * @atomicservice
29 * @since 12
30 */
31declare type Initializer<T> = () => T;
32
33/**
34 * Defines a modifier which can update attributes to native side.
35 *
36 * @implements AttributeModifier<T>
37 * @syscap SystemCapability.ArkUI.ArkUI.Full
38 * @crossplatform
39 * @atomicservice
40 * @since 12
41 */
42export declare class AttributeUpdater<T, C = Initializer<T>> implements AttributeModifier<T> {
43
44  /**
45   * Defines the normal update attribute function.
46   *
47   * @param { T } instance
48   * @syscap SystemCapability.ArkUI.ArkUI.Full
49   * @crossplatform
50   * @atomicservice
51   * @since 12
52   */
53  applyNormalAttribute?(instance: T): void;
54
55  /**
56   * Defines a function for initialization.
57   *
58   * @param { T } instance
59   * @syscap SystemCapability.ArkUI.ArkUI.Full
60   * @crossplatform
61   * @atomicservice
62   * @since 12
63   */
64  initializeModifier(instance: T): void;
65
66  /**
67   * Get attribute of the modifier.
68   *
69   * @returns { T | undefined } The attribute of the modifier.
70   * @syscap SystemCapability.ArkUI.ArkUI.Full
71   * @crossplatform
72   * @atomicservice
73   * @since 12
74   */
75  get attribute(): T | undefined;
76
77  /**
78   * Used to update constructor params.
79   *
80   * @type { C }
81   * @syscap SystemCapability.ArkUI.ArkUI.Full
82   * @crossplatform
83   * @atomicservice
84   * @since 12
85   */
86  updateConstructorParams: C;
87
88  /**
89   * Defines a function executed when component changed.
90   *
91   * @param { T } component
92   * @syscap SystemCapability.ArkUI.ArkUI.Full
93   * @crossplatform
94   * @atomicservice
95   * @since 12
96   */
97  onComponentChanged(component: T): void;
98}
99
100/**
101 * function that returns by the function updateConstructorParams.
102 *
103 * @typedef { function } Initializer<T>
104 * @param { Object[] } params
105 * @returns { T }
106 * @syscap SystemCapability.ArkUI.ArkUI.Full
107 * @crossplatform
108 * @atomicservice
109 * @since 20
110 * @arkts 1.2
111 */
112export type Initializer<T> = (...params: Object[]) => T;
113
114/**
115 * Defines a modifier which can update attributes to native side.
116 *
117 * @implements AttributeModifier<T>
118 * @syscap SystemCapability.ArkUI.ArkUI.Full
119 * @crossplatform
120 * @atomicservice
121 * @since 20
122 * @arkts 1.2
123 */
124export declare class AttributeUpdater<T> implements AttributeModifier<T> {
125  /**
126   * Defines a function for initialization.
127   *
128   * @param { T } instance
129   * @syscap SystemCapability.ArkUI.ArkUI.Full
130   * @crossplatform
131   * @atomicservice
132   * @since 20
133   * @arkts 1.2
134   */
135  initializeModifier(instance: T): void;
136
137  /**
138   * Get attribute of the modifier.
139   *
140   * @returns { T | undefined } The attribute of the modifier.
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @crossplatform
143   * @atomicservice
144   * @since 20
145   * @arkts 1.2
146   */
147  get attribute(): T | undefined;
148
149  /**
150   * Used to update constructor params.
151   *
152   * @type { Initializer<T> }
153   * @syscap SystemCapability.ArkUI.ArkUI.Full
154   * @crossplatform
155   * @atomicservice
156   * @since 20
157   * @arkts 1.2
158   */
159  get updateConstructorParams(): Initializer<T>;
160
161  /**
162   * Defines a function executed when component changed.
163   *
164   * @param { T } component
165   * @syscap SystemCapability.ArkUI.ArkUI.Full
166   * @crossplatform
167   * @atomicservice
168   * @since 20
169   * @arkts 1.2
170   */
171  onComponentChanged(component: T): void;
172}