Home Reference Source Test Repository
import ComponentRegistry from 'rizzo-next/src/core/component_registry.js'
public class | source

ComponentRegistry

Register components with Rizzo

Test:

Constructor Summary

Public Constructor
public

Constructs the ComponentRegistry

Member Summary

Public Members
public
public

logger: *

Method Summary

Public Methods
public

createInstanceOf(Component: Component, options: [object]): object

Create an instance of a given component.

public

Get instances of a specific component, by either it's string or Constructor

public

register(Constructor: Component)

Add a new Component to the registry.

Public Constructors

public constructor source

Constructs the ComponentRegistry

Params:

NameTypeAttributeDescription
options.logger Logger

Instance of a logger

Public Members

public components: * source

public logger: * source

Public Methods

public createInstanceOf(Component: Component, options: [object]): object source

Create an instance of a given component. Will also register the component.

Params:

NameTypeAttributeDescription
Component Component

A constructor that extends Component

options [object]

Options to pass to the constructor

Return:

object

Instance of the component

public getInstancesOf(Component: Component | String): Array source

Get instances of a specific component, by either it's string or Constructor

Params:

NameTypeAttributeDescription
Component Component | String

Either the Constructor or the string name of a constructor

Return:

Array

An array of all instances of the component

Example:

rizzo.renderComponent(MastheadComponent, {});
rizzo.registry.getInstancesOf(MastheadComponent); // [MastheadComponent]

public register(Constructor: Component) source

Add a new Component to the registry.
Must extend the Component constructor.
Components will only be registered in browsers that support Function.name since this is mostly for debugging anyways.

Params:

NameTypeAttributeDescription
Constructor Component

The component being added