Lines Matching refs:Trace
1 # \@ObservedV2 and \@Trace Decorators: Observing Class Property Changes
3 …properties in class objects, you can use the \@ObservedV2 decorator and \@Trace decorator to decor…
7 >The \@ObservedV2 and \@Trace decorators are supported since API version 12.
12 The \@ObservedV2 and \@Trace decorators are used to decorate classes and properties in classes so t…
14 - \@ObservedV2 and \@Trace must come in pairs. Using either of them alone does not work.
15 - If a property decorated by \@Trace changes, only the component bound to the property is instructe…
16 …s property trigger UI re-renders only when the property is decorated by \@Trace and the class is d…
17 …hild class trigger UI re-renders only when the property is decorated by \@Trace and the owning cla…
18 - Attributes that are not decorated by \@Trace cannot detect changes nor trigger UI re-renders.
119 …is where the class decorator \@ObservedV2 and member property decorator \@Trace come into the pict…
128 | \@Trace member property decorator| Description …
135 In classes decorated by \@ObservedV2, properties decorated by \@Trace are observable. This means th…
137 - Changes to properties decorated by \@Trace in nested classes decorated by \@ObservedV2
142 @Trace age: number = 100;
165 - Changes to properties decorated by \@Trace in inherited classes decorated by \@ObservedV2
170 @Trace name: string = "Tom";
191 - Changes to static properties decorated by \@Trace in classes decorated by \@ObservedV2
196 @Trace static count: number = 1;
213 - Changes caused by the APIs listed below to properties of built-in types decorated by \@Trace
224 Note the following constraints when using the \@ObservedV2 and \@Trace decorators:
226 - The member property that is not decorated by \@Trace cannot trigger UI re-renders.
232 @Trace age: number = 8;
241 // age is decorated by @Trace and can trigger re-renders when used in the UI.
246 // id is not decorated by @Trace and cannot trigger re-renders when used in the UI.
266 - \@Trace cannot be used in classes that are not decorated by \@ObservedV2.
271 @Trace name: string = "Tom"; // Incorrect usage. An error is reported at compile time.
275 - \@Trace is a decorator for properties in classes and cannot be used in a struct.
280 @Trace message: string = "Hello World"; // Incorrect usage. An error is reported at compile time.
287 - \@ObservedV2 and \@Trace cannot be used together with [\@Observed](arkts-observed-and-objectlink.…
292 @Trace name: string = "Tom"; // Incorrect usage. An error is reported at compile time.
301 - Classes decorated by @ObservedV2 and @Trace cannot be used together with [\@State](arkts-state.md…
307 @Trace jobName: string = "Teacher";
311 @Trace name: string = "Tom";
312 @Trace age: number = 25;
344 @Trace jobName: string = "Teacher";
348 @Trace name: string = "Tom";
349 @Trace age: number = 25;
386 …s decorated by \@ObservedV2 and its **length** property is decorated by \@Trace, changes to **leng…
388 The example demonstrates how \@Trace is stacked up against [\@Track](arkts-track.md) and [\@State](…
390 * Click **Button("change length")**, in which **length** is a property decorated by \@Trace. The ch…
397 @Trace length: number = 21; // If length changes, the bound component is re-rendered.
443 Properties in base or derived classes are observable only when decorated by \@Trace.
454 @Trace age: number = 0;
518 ### Decorating an Array of a Built-in Type with \@Trace
520 With an array of a built-in type decorated by \@Trace, changes caused by supported APIs can be obse…
521 …*numberArr** property in the \@ObservedV2 decorated **Arr** class is an \@Trace decorated array. I…
529 @Trace numberArr: number[] = [];
622 ### Decorating an Object Array with \@Trace
624 …array and the **age** property in the **Person** class are decorated by \@Trace. As such, changes …
632 @Trace age: number = 0;
642 @Trace personList: Person[] = [];
692 ### Decorating a Property of the Map Type with \@Trace
694 * With a property of the Map type decorated by \@Trace, changes caused by supported APIs, such as *…
695 …ecorated by \@ObservedV2 and its **memberMap** property is decorated by \@Trace; as such, changes …
700 @Trace memberMap: Map<number, string> = new Map([[0, "a"], [1, "b"], [3, "c"]]);
746 ### Decorating a Property of the Set Type with \@Trace
748 * With a property of the Set type decorated by \@Trace, changes caused by supported APIs, such as *…
749 …ecorated by \@ObservedV2 and its **memberSet** property is decorated by \@Trace; as such, changes …
754 @Trace memberSet: Set<number> = new Set([0, 1, 2, 3, 4]);
795 ### Decorating a Property of the Date Type with \@Trace
797 * With a property of the Date type decorated by \@Trace, changes caused by the following APIs can b…
798 …rated by \@ObservedV2 and its **selectedDate** property is decorated by \@Trace; as such, changes …
803 @Trace selectedDate: Date = new Date('2021-08-08')