mail
capability. This allows you to trigger an import for all or specific sessions at any time during runtime. When the import_frontend_module
method is called, this triggers a dynamic import() call in the front-end.
The import_frontend_module
method takes the module_key
and specifier
arguments. The module_key
is an identifier used to store the reference to the module, which will be used later to call the module’s functions. The specifier
is the path to the module, such as /static/mymodule.js
. It needs to be available to the front-end, so storing in the /static/
folder is recommended.
The following code imports a module during event handling.
/static/script.js?3
.call_frontend_function
method of state. This function takes three arguments. The first, module_key
is the identifier used to import the module. The second, function_name
is the name of the exported front-end function. The third, args
is a List
containing the arguments for the call.
The following event handler triggers the front-end function defined in the section above.
import_script
method. This method takes two arguments. The first, script_key
is the identifier used to import the script. The second, path
is the path to the file. The specified path must be available to the front-end, so storing it in your application’s ./static
folder is recommended.
import_script
syntax is only used for side effects; you’ll only be able to call functions from the back-end using modules that have been previously imported via import_frontend_module
.import_script
and import_stylesheet
methods take a url
argument, which is the URL to the script or stylesheet.
globalThis.core
, unlocking all sorts of functionality. Notably, you can use getUserState()
to get values from state.