Interface: ActorProviderProps
API / @xmachines/play-svelte / ActorProviderProps
Defined in: packages/play-svelte/src/actor-context.svelte.ts:81
The framework-agnostic base props. Every ActorProvider implementation shares
them: React, Vue, Solid, and Svelte. TRegistry holds the
DefineRegistryResult type of the framework. RenderErrorHandler comes from
@xmachines/json-render-core, and a second generic parameter is therefore not
necessary.
Each framework package extends this interface with its fallback field, its
onError field, and its children field.
Example
import type { BaseActorProviderProps, ViewActor } from "@xmachines/play-view";import type { DefineRegistryResult } from "@xmachines/json-render-react";
interface ActorProviderProps extends BaseActorProviderProps<DefineRegistryResult> { fallback?: React.ReactNode; children: React.ReactNode;}Extends
BaseActorProviderProps<DefineRegistryResult>
Extended by
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
actor | ViewActor | The actor instance with the currentView signal. It requires the Viewable capability. | BaseActorProviderProps.actor | packages/play-view/src/view-types.ts:169 |
children | Snippet | - | - | packages/play-svelte/src/actor-context.svelte.ts:123 |
fallback? | Snippet<[]> | - | - | packages/play-svelte/src/actor-context.svelte.ts:82 |
onError? | (error, reset) => void | The optional callback. The provider calls it when the outer <svelte:boundary> catches an error, and when the resolution of the store fails. The second parameter is the reset callback, for a retry that the host starts. The reset resolves the view that the actor holds at the moment of the call, and not the view that failed: the host can keep the callback on a “Retry” button while the actor moves on. A reset that the host calls from inside this handler starts no second retry, because no input changed between the two attempts. ONE reset serves a failure of either kind, and it retries the failure on the screen NOW. A host can keep the callback — a “Retry” button of a toast outlives the failure that opened it — and the press retries whatever failure stands at that moment, and not the one that handed the callback out. The four other renderers hand the host one reset the same way, and the five hold ONE contract. Each reset does nothing after the provider is destroyed. The host can hold the callback — a “Retry” button of a toast outlives the route that opened it — and a reset of a provider that is gone would report to the host a second time, from a component that renders nothing. The callback stays safe to hold, and safe to call. While the error is active, the provider renders the fallback instead of its children. The provider clears the error on the next view emission (when currentView changes), so a view transition retries the render. Element-level catalog component throws are caught upstream by the per-element boundary of @json-render, and reported through onRenderError. This boundary is the outer net for everything else. A handler that THROWS reaches no caller. The provider contains that throw, and it writes the throw to console.error. Svelte catches such a throw itself, and it leaves its own calling_on_error flag raised: every later reset of the host then raises svelte_boundary_reset_onerror, so the “Retry” button throws and the boundary can never clear. Report a failure from this handler. To ESCALATE one, raise it from a task of your own — queueMicrotask(() => { throw error; }) — which reaches the global handler of the page and leaves the containment whole. The five renderers hold this one rule. | - | packages/play-svelte/src/actor-context.svelte.ts:122 |
onRenderError? | RenderErrorHandler | The provider calls it when one catalog component throws during a render. This handler replaces every onRenderError of defineRegistry. | BaseActorProviderProps.onRenderError | packages/play-view/src/view-types.ts:183 |
registryResult | DefineRegistryResult | The complete result of defineRegistry(). It holds the component registry and the factory of the action handlers. | BaseActorProviderProps.registryResult | packages/play-view/src/view-types.ts:171 |
store? | StateStore | The optional external StateStore, which is the controlled mode. With this option, the provider ignores spec.state, and this store is the single source of truth. Without it, the provider makes a new @xstate/store atom for each view transition, with the values of spec.state. | BaseActorProviderProps.store | packages/play-view/src/view-types.ts:178 |