lynx: requireModule() static method
Used to import modules. Just like NodeJS's require.
requireModule will load the module synchronously. During the loading, the JavaScript thread will be hang. No JavaScript code will be executed.
Syntax
Parameters
path
The path of the module. Can be a remote path, or a path inside the template.
Return Value
The exported value of the module.
Exception
requireModule will throw an exception when:
- Network error
- Module execute error
- Timeout
The error can be catch and handled by using try-catch.
Timeout
To avoid JavaScript thread hang forever when loading remote resources, requireModule will throw an exception 5 seconds after the request is sent.
Examples
Loading remote resources
Re-try on timeout
Compatibility
LCD tables only load in the browser