Lines Matching refs:module

3module-principle.md), the loading and execution of modules may cause side effects. Side effects re…
9module is imported, the top-level code in the entire module file is executed immediately, not just…
11 // module.ets
16 import {data} from './module' // When data is imported, the console.log file in module.ets is execu…
32 // module.ets
36 import { data } from './module'
43 … the code only when necessary, instead of executing the code immediately when the module is loaded.
45 // module.ets
52 import { data } from './module'
62 The top-level code or imported module may directly operate global variables to change the global st…
64 // module.ets
65 export let data1 = "data from module"
69 export let data2 = "data from side effect module"
73 import {data1} from './module' // The value of the global variable someGlobalVar may be expected to…
76 …he value of someGlobalVar is changed to 200 because the sideEffectModule module is loaded to main.…
80 import {data1} from ."/module" // Change the value of the global variable someGlobalVar to 100.
92 data from module
97 When a module is loaded, the value of the global variable globalThis.someGlobalVar is directly chan…
101 … and executed only when necessary, instead of being executed immediately when the module is loaded.
103 // module.ets
104 export let data1 = "data from module"
110 export let data2 = "data from side effect module"
116 import { data1, changeGlobalVar } from './module'
119 changeGlobalVar (); // Execute the code when necessary instead of when the module is loaded.
124 import { data1 } from "./module"
136 data from module
142 The top-level code or imported module may directly modify the state variable information of the app…
144 // module.ets
145 export let data = "data from module"
149 import {data} from ."/module" // Change SomeAppStorageVar in AppStorage to 200.
154 …// The expected value is 100. However, the value has been changed to 200 due to module import. How…
177 When a module is loaded, the value of SomeAppStorageVar in AppStorage is changed, affecting other m…
183 … and executed only when necessary, instead of being executed immediately when the module is loaded.
185 // module.ets
186 export let data = "data from module"
192 import { data } from "./module"
247 …zation supports circular dependency. That is, module A depends on module B, and module B depends o…
271 Avoid circular dependency between modules and ensure that the module loading sequence is clear and …
277 // module.ets
278 export let data = "data from module"
282 import lazy { data } from "./module"
283 console.log (globalThis.someGlobalVar); // The module is not executed due to the lazy feature. The …
284 console.log (data); // Variables of the module are used. When the module is executed, the value of …
289 data from module
293 …, the corresponding module is executed when the module variable is used, and the modification of s…
297 … and executed only when necessary, instead of being executed immediately when the module is loaded.
299 // module.ets
300 export let data = "data from module"
306 import lazy { data, initialize } from "./module"
314 data from module