Common API¶
All modules have the following common API.
init()¶
Asynchronous method that resolves when the modules finishes its initialization.
Although loadModule returns the module already initialized, this method is maintained for compatibility purposes.
Output:
promise(Promise): Promise that is resolved when the module is initialized. The promise returns the module.
Example:
getModuleName()¶
Returns the name identifier of the module.
Output:
name(string): Module name
Example:
getModuleVersion()¶
Returns the module version.
Output:
version(string): module version
Example:
getPluginsList()¶
Returns a list with the current plugins in use (if any).
Output:
plugins(string[]): Plugins list.
Example:
getClientId()¶
Returns the client id used in this instance (if any).
Output:
client_id(string | null): client id
Example:
getModuleId()¶
Returns the unique per-instance id of the module. Use it to look the instance back up through the registry (see Lifecycle).
Output:
module_id(string): unique per-instance id.
Example:
destroy()¶
Asynchronous method that permanently destroys the module and releases every resource it holds. Calling it again is safe and does nothing, and the instance must not be used afterward. See Lifecycle for the create/destroy pattern.
Output:
promise(Promise): resolves once the module is destroyed.
Example:
isDestroyed()¶
Returns true once destroy() has been called on the instance.
Output:
destroyed(boolean):trueifdestroy()has been called.
Example:
Module registry¶
The module manager exposes synchronous queries over the modules that are currently live, registered on construction
and removed once their destroy() resolves. Import them from @3ddv/dvm (or @3ddv/dvm-internal), not from a module
instance. See Lifecycle for the create/destroy pattern.
getModules()¶
Returns every top-level module currently live in the registry. Synchronous.
Output:
modules(Module[]): the live top-level modules (empty array when none are loaded).
Example:
getModuleById()¶
Looks up a single live module by its per-instance id (the value returned by getModuleId()). Synchronous.
Input:
module_id(string): the per-instance module id to resolve.
Output:
module(Module | undefined): the matching module, orundefinedif no live module has that id.
Example:
getModulesByType()¶
Returns every live module of a given type, e.g. "map_viewer" or "3d_viewer". Synchronous.
Input:
module_type(string): the module type to filter by.
Output:
modules(Module[]): the live modules of that type (empty array when none match).