ComponentRegistry

ComponentRegistry is a singleton that maps component names (strings) to Component classes/constructors. This is essential for loading components from JSON data where only the class name is known.

Constructor

new ComponentRegistry()

Methods

(static) clear()

Clear the registry (mostly for testing).

(static) create(name, …args) → {Component|null}

Create a new instance of a component by name.

Parameters:
NameTypeAttributesDescription
namestring

The name of the component.

argsany<repeatable>

Arguments to pass to the constructor.

Returns:

The new component instance, or null if not found.

Type: 
Component | null

(static) get(name) → {class|undefined}

Get a component class by name.

Parameters:
NameTypeDescription
namestring

The name of the component.

Returns:

The component class constructor.

Type: 
class | undefined

(static) nameOf()

Return the registered serialized name for a component constructor or instance. Unregistered components fall back to their JavaScript constructor name.

(static) register(name, componentClass)

Register a component class with the registry.

Parameters:
NameTypeDescription
namestring

The name to register the component under (usually class.name).

componentClassclass

The class constructor.