Skip to content

Interface: DefineRegistryOptions<C>

API / @xmachines/play-svelte / DefineRegistryOptions

Defined in: packages/play-svelte/src/define-registry.ts:94

The options of defineRegistry.

The shape is the same as the shape above it, but the untyped Record<string, DefineRegistryActionFn> becomes the catalog-typed Actions<C> map.

Type Parameters

Type Parameter
C extends Catalog

Properties

PropertyTypeDescriptionDefined in
actions?Actions<C>The catalog-typed map of the action handlers. Each handler receives params with the exact schema of the catalog action, or undefined when the caller gives no params. It also receives the setState argument and the state argument of the package above. Test for undefined before you read a param: Example actions: { login: async (params) => { if (!params) return; actor.send({ type: "auth.login", username: params.username }); }, logout: async () => actor.send({ type: "auth.logout" }), }packages/play-svelte/src/define-registry.ts:118
components?Components<C>The Svelte component implementations, with the catalog component name as the key.packages/play-svelte/src/define-registry.ts:98
onRenderError?RenderErrorHandlerThe callback that the renderer calls when a catalog component throws during a render. The inner <svelte:boundary> of @xmachines/json-render-svelte catches the error, and that boundary wraps each element. With this callback, the default console.error(...) fallback does not run: the renderer removes the component from the DOM, and your callback receives the error and the name of the element type. You can then report the error, or you can recover from it. Example const { registry, handlers } = defineRegistry(authCatalog, { components: { Login, Dashboard }, actions: { ... }, onRenderError(error, elementType) { console.warn(Component <${elementType}> crashed:, error); reportToSentry(error, { componentType: elementType }); }, }); Param error The value that the component threw. It is not always an Error instance. Param elementType The name of the catalog component that failed, for example "Dashboard".packages/play-svelte/src/define-registry.ts:143