lynx: requireModuleAsync() static method
Used to import modules. Just like the requireModule method, but loading asynchronously.
During the loading, the other JavaScript code can be executed.
The module loaded by requireModuleAsync needs to use a specific format. Use @lynx-js/runtime-wrapper-webpack-plugin to generate modules that are requireModuleAsync-loadable.
Syntax
Parameters
path
The path of the module. Can be a remote path, or a path inside the template.
callback
The callback to be executed after the require is finished
- If any error occurs, an error will be passed as the first parameter.
- Otherwise, a
nullwill be passed as the first parameter, and the exported value of the module will be passed as the second parameter.
Return Value
None (undefined).
Exception
requireModuleAsync will return an error in callback when:
- Network error
- Module execute error
Examples
Loading remote resources
Promisify
Compatibility
LCD tables only load in the browser