Skip to content

Function: createRenderer()

API / @xmachines/play-dom / createRenderer

function createRenderer<C>(catalog, componentMap): (actor, container, options?) => () => void;

Defined in: packages/play-dom/src/create-renderer.ts:88

Creates a DOM renderer factory from a catalog and a component map. You can use the factory more than one time.

It returns a mount(actor, container, options?) function. That function connects the PlayRenderer in one call, and it returns a disconnect cleanup function.

Type Parameters

Type Parameter
C extends Catalog<SchemaDefinition<SchemaType<string, unknown>, SchemaType<string, unknown>>, unknown>

Parameters

ParameterTypeDescription
catalogCThe json-render Catalog. It describes the schema of each component and of each action.
componentMapComponentRegistry<C>The component implementations, with the catalog component name as the key.

Returns

A mount function. It accepts (actor, container, options?), and it returns disconnect.

(actor, container, options?) => () => void

Remarks

createRenderer manages registryResult internally. It calls defineRegistry one time, and it uses that result in every mount() call. Therefore the options type of mount holds no registryResult: createRenderer always gives it, and you cannot replace it.

Two situations need a different function. In the first, your code calls registryResult.executeAction() itself, outside the emit and on flow. In the second, you give more provider options, such as navigate, onRenderError, or functions. Use createPlayUI, which accepts the complete CreatePlayUIOptions. You can also use defineRegistry with PlayRenderer directly.