Skip to content

Function: attachRenderErrorHandler()

API / @xmachines/play-view / index / attachRenderErrorHandler

function attachRenderErrorHandler<TRegistry>(registry, handler): TRegistry;

Defined in: packages/play-view/src/provider-guards.ts:78

Copies a component registry, and puts an onRenderError handler into the copy.

The function defines the handler as an own property of the copy. That property is not enumerable, and it is configurable (D-19 gives one convention of the injection for every framework renderer). The handler therefore replaces each handler of the defineRegistry level, and it does not appear in an enumeration of the component entries of the registry.

The function never changes the registry of the caller: it returns the copy of withRenderErrorHandler, which keeps the slot metadata of the registry. Therefore a caller that needs a handler for each instance, such as an onRenderError prop of ActorProvider, can share one result of defineRegistry between the providers in a safe way.

Type Parameters

Type ParameterDescription
TRegistry extends objectThe component registry type of the framework.

Parameters

ParameterTypeDescription
registryTRegistryThe component registry from defineRegistry().registry.
handlerOnRenderErrorThe renderer calls it with (error, name, info) for each failure that it reports. info.kind names the kind of the failure, such as "element" or "root".

Returns

TRegistry

A shallow copy of registry, with onRenderError on it.