Registry for view factories

A view factory is used to create a view for a LimeObject. Multiple factories can be registered for the same view type, and when that is done the factory returned from getFactory will invoke each one in the order that they were added, using the return value from each factory as input for the next factory in the chain.

Example

Registering a view factory

const factory = (
limeobject: LimeObject,
context: LimeWebComponentContext,
view?: ListItem
): ListItem => {
return {
...view,
icon: 'dog',
};
};
registry.registerFactory('list', factory);

Example

Using a factory to create a view

const createListItem = registry.getFactory('list');
const listItem = createListItem(limeobject, context);

Hierarchy

  • ViewFactoryRegistry

Methods

  • Get a factory for the given view type

    Returns

    a factory for the given view type

    Type Parameters

    • T = unknown

    Parameters

    • type: string

      the type of view to get a factory for

    Returns ViewFactory<T>

  • Register a factory for a given view type

    Type Parameters

    • T = unknown

    Parameters

    • type: string

      the type of view to get a factory for

    • factory: ViewFactory<T>

      factory function to create a view of the specific type

    Returns void