createLume
createLume() creates a new Lume application instance.
Signature
Section titled “Signature”Returns
Section titled “Returns”A LumeApp object with the following methods:
LumeApp API
Section titled “LumeApp API”component(name, definition)
Section titled “component(name, definition)”Registers a component definition under a name.
| Parameter | Type | Description |
|---|---|---|
name | string | The component name (matches data-lume attribute) |
definition | ComponentDefinition | The result of defineComponent() |
Returns: LumeApp (chainable)
mount(root?)
Section titled “mount(root?)”Scans the DOM for [data-lume] elements and initializes matching components.
| Parameter | Type | Default | Description |
|---|---|---|---|
root | HTMLElement | Document | document | The root to scan |
Returns: LumeApp (chainable)
unmount()
Section titled “unmount()”Destroys all component instances, running cleanup functions and removing effects.
get<T>(id)
Section titled “get<T>(id)”Retrieves a component’s public API by its data-lume-id.
Returns: T | undefined
require<T>(id)
Section titled “require<T>(id)”Like get(), but throws an error if the component is not found.
Returns: T (throws if not found)
emit(name, detail?)
Section titled “emit(name, detail?)”Emits a local event within this app.
listen(name, handler)
Section titled “listen(name, handler)”Listens to local events within this app.
global.emit(name, detail?)
Section titled “global.emit(name, detail?)”Emits a global event shared across all Lume apps.
global.listen(name, handler)
Section titled “global.listen(name, handler)”Listens to global events shared across all Lume apps.
use(plugin)
Section titled “use(plugin)”Applies a plugin to this app.
| Parameter | Type | Description |
|---|---|---|
plugin | Plugin | A function (app: LumeApp) => void |
Returns: LumeApp (chainable)