• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ArkTS Changelog
2
3## cl.ArkTS.1 Lazy Import Now Does Not Affect the Timing of Asynchronous Task Execution
4
5**Access Level**
6
7Other
8
9**Reason for Change**
10
11The use of lazy import variables changes the timing of asynchronous task execution.
12
13**Change Impact**
14
15This change is a non-compatible change.
16
17Before change: Using lazy import variables changes the timing of asynchronous task execution.
18
19After change: Using lazy import variables does not change the timing of asynchronous task execution.
20
21**Start API Level**
22
2312
24
25**Change Since**
26
27OpenHarmony SDK 5.0.1.44
28
29**Key API/Component Changes**
30
31N/A
32
33**Adaptation Guide**
34
35Check all the scenarios where lazy import variables are used.
36
37An example use scenario is as follows:
38```typescript
39// myLog.ets
40export class MyLog {
41    static log(s:string) {
42        console.log(s);
43    }
44}
45
46// test.ets
47import lazy { MyLog } from './myLog'
48
49async function asyncFunc(f?:string): Promise<number> {
50    MyLog.log("asyncFunc start");
51    return new Promise(resolve => {
52        resolve(0);
53    });
54}
55export async function taskTest() {
56    MyLog.log("taskTest start");
57    asyncFunc().then((res) => {
58        MyLog.log("asyncFunc then");
59    });
60    MyLog.log("taskTest end");
61}
62```
63Before the change, lazy import affects the timing of asynchronous task execution. The output is as follows:
64```
65taskTest start
66asyncFunc start
67asyncFunc then
68taskTest end
69```
70After the change, the output is as follows:
71```
72taskTest start
73asyncFunc start
74taskTest end
75asyncFunc then
76```
77This change fixes the defect so that lazy import does not affect the timing of asynchronous task execution.
78