@xmachines/docs 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -16
- package/api/@xmachines/play/README.md +11 -100
- package/api/@xmachines/play/errors/README.md +8 -0
- package/api/@xmachines/play/{classes → errors/classes}/NonNullableError.md +6 -6
- package/api/@xmachines/play/{classes → errors/classes}/PlayError.md +35 -10
- package/api/@xmachines/play/index/README.md +75 -0
- package/api/@xmachines/play/{functions → index/functions}/asCleanup.md +2 -2
- package/api/@xmachines/play/{functions → index/functions}/assertNonNullable.md +2 -2
- package/api/@xmachines/{play-actor → play/index}/functions/shallowEqualExcept.md +3 -3
- package/api/@xmachines/play/{type-aliases → index/type-aliases}/Cleanup.md +3 -3
- package/api/@xmachines/play/{type-aliases → index/type-aliases}/DisposeKey.md +2 -2
- package/api/@xmachines/play/{type-aliases → index/type-aliases}/PlayEvent.md +4 -4
- package/api/@xmachines/play/{variables → index/variables}/DISPOSE.md +2 -2
- package/api/@xmachines/play-actor/README.md +78 -229
- package/api/@xmachines/play-actor/interfaces/ActorEvent.md +18 -0
- package/api/@xmachines/play-actor/interfaces/PlayActor.md +73 -0
- package/api/@xmachines/play-dom/README.md +28 -40
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +12 -11
- package/api/@xmachines/play-dom/functions/asCleanup.md +78 -0
- package/api/@xmachines/play-dom/functions/createPlayUI.md +4 -4
- package/api/@xmachines/play-dom/functions/createRenderer.md +1 -1
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +3 -3
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +3 -3
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +6 -6
- package/api/@xmachines/play-dom/type-aliases/Cleanup.md +2 -2
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +29 -12
- package/api/@xmachines/play-dom-router/README.md +70 -70
- package/api/@xmachines/play-dom-router/classes/DomRouterBridge.md +22 -21
- package/api/@xmachines/{play-vue-router → play-dom-router}/classes/RouteMap.md +12 -6
- package/api/@xmachines/play-dom-router/functions/asCleanup.md +78 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +3 -8
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +9 -3
- package/api/@xmachines/play-dom-router/functions/createRouter.md +8 -14
- package/api/@xmachines/play-dom-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +70 -26
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +24 -21
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterConnection.md +8 -8
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +36 -23
- package/api/@xmachines/play-dom-router/type-aliases/Cleanup.md +2 -2
- package/api/@xmachines/play-dom-router/variables/DISPOSE.md +2 -2
- package/api/@xmachines/play-react/README.md +17 -39
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +14 -10
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +6 -6
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +4 -4
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-react/variables/schema.md +52 -0
- package/api/@xmachines/play-react-router/README.md +22 -50
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +17 -16
- package/api/@xmachines/play-react-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +11 -8
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +16 -9
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-react-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-router/README.md +104 -196
- package/api/@xmachines/play-router/errors/README.md +15 -0
- package/api/@xmachines/play-router/errors/classes/DuplicateBridgeError.md +191 -0
- package/api/@xmachines/play-router/errors/classes/DuplicateRoutePathError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/EmptyRoutePathError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/InvalidBasePathError.md +200 -0
- package/api/@xmachines/play-router/errors/classes/InvalidRoutePatternError.md +203 -0
- package/api/@xmachines/play-router/errors/classes/InvalidStateIdError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/MissingBasePathParamError.md +199 -0
- package/api/@xmachines/play-router/errors/classes/RouterSyncError.md +192 -0
- package/api/@xmachines/play-router/errors/classes/UnknownStateTypeError.md +182 -0
- package/api/@xmachines/play-router/index/README.md +75 -0
- package/api/@xmachines/play-router/{classes → index/classes}/RouteMap.md +12 -6
- package/api/@xmachines/play-router/{classes → index/classes}/RouterBridgeBase.md +19 -17
- package/api/@xmachines/play-router/{functions → index/functions}/buildPlayRouteEvent.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/buildRouteTree.md +14 -4
- package/api/@xmachines/play-router/{functions → index/functions}/cleanFrameworkParams.md +3 -4
- package/api/@xmachines/play-router/{functions → index/functions}/createRouteMapFromTree.md +13 -6
- package/api/@xmachines/play-router/{functions → index/functions}/createRouterConnection.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/detectDuplicateRoutes.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/extractQuery.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/extractRouteParams.md +3 -3
- package/api/@xmachines/play-router/{functions → index/functions}/findRouteById.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/findRouteByPath.md +2 -2
- package/api/@xmachines/play-router/index/functions/getPatternParamNames.md +29 -0
- package/api/@xmachines/play-router/index/functions/getRequiredPatternParamNames.md +39 -0
- package/api/@xmachines/play-router/{functions → index/functions}/isMountableBridge.md +2 -2
- package/api/@xmachines/play-router/index/functions/joinBasePath.md +37 -0
- package/api/@xmachines/play-router/{functions → index/functions}/mountKey.md +2 -2
- package/api/@xmachines/play-router/index/functions/normalizeBasePath.md +43 -0
- package/api/@xmachines/play-router/{functions → index/functions}/openProviderBridge.md +14 -14
- package/api/@xmachines/play-router/index/functions/pickOwnParams.md +41 -0
- package/api/@xmachines/play-router/{functions → index/functions}/repointProviderBridge.md +2 -2
- package/api/@xmachines/play-router/index/functions/resolveBasePath.md +51 -0
- package/api/@xmachines/play-router/{functions → index/functions}/resolveFrameworkParams.md +11 -13
- package/api/@xmachines/play-router/{functions → index/functions}/sanitizePathname.md +2 -2
- package/api/@xmachines/play-router/index/functions/stripBasePath.md +44 -0
- package/api/@xmachines/play-router/{functions → index/functions}/validateRouteFormat.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/validateStateExists.md +2 -2
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/BasePathOptions.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/BuildPlayRouteEventOptions.md +13 -0
- package/api/@xmachines/play-router/index/interfaces/FrameworkParamsSource.md +47 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/LocationLike.md +6 -6
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/MountableRouterBridge.md +9 -9
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/OpenProviderBridgeArgs.md +13 -13
- package/api/@xmachines/play-router/index/interfaces/PlayRouteEvent.md +130 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/PlayRouterProviderBaseProps.md +15 -15
- package/api/@xmachines/play-router/index/interfaces/ResolvedBasePath.md +14 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/ResolvedRoutePath.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/Routable.md +26 -0
- package/api/@xmachines/play-router/index/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteInfo.md +11 -11
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteMapping.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/RouteMatch.md +12 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteNode.md +13 -13
- package/api/@xmachines/play-router/index/interfaces/RouteObject.md +34 -0
- package/api/@xmachines/play-router/index/interfaces/RouteTree.md +27 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteWatcherHandle.md +7 -7
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouterBridge.md +5 -5
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouterConnection.md +10 -10
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/WindowLike.md +4 -4
- package/api/@xmachines/play-router/index/type-aliases/PlayRouterBridgeConstructor.md +46 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteData.md +12 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteDataResolver.md +31 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteMetadata.md +11 -0
- package/api/@xmachines/{play-xstate → play-router/index}/variables/DISPOSE.md +3 -3
- package/api/@xmachines/play-router/index/variables/NO_BASE_PATH.md +18 -0
- package/api/@xmachines/play-router/index/variables/ROOT_NODE_ID.md +18 -0
- package/api/@xmachines/play-router/xstate/README.md +53 -0
- package/api/@xmachines/play-router/{functions → xstate/functions}/createRouteMap.md +8 -6
- package/api/@xmachines/play-router/{functions → xstate/functions}/extractMachineRoutes.md +4 -4
- package/api/@xmachines/play-router/xstate/functions/getNavigableRoutes.md +35 -0
- package/api/@xmachines/play-router/{functions → xstate/functions}/getRoutableRoutes.md +6 -6
- package/api/@xmachines/play-router/{functions → xstate/functions}/getRouteMappings.md +7 -7
- package/api/@xmachines/play-router/{functions → xstate/functions}/getTransitionReachableRoutes.md +2 -2
- package/api/@xmachines/play-router/{functions → xstate/functions}/isRouteReachable.md +2 -2
- package/api/@xmachines/play-router/{functions → xstate/functions}/machineToGraph.md +2 -2
- package/api/@xmachines/play-router/xstate/functions/routeExists.md +26 -0
- package/api/@xmachines/play-router/xstate/interfaces/MachineEdgeData.md +15 -0
- package/api/@xmachines/play-router/xstate/interfaces/MachineNodeData.md +17 -0
- package/api/@xmachines/play-router/{type-aliases → xstate/type-aliases}/MachineGraph.md +2 -2
- package/api/@xmachines/play-signals/README.md +2 -24
- package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
- package/api/@xmachines/play-signals/type-aliases/Cleanup.md +2 -2
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +14 -31
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/schema.md +71 -0
- package/api/@xmachines/play-solid-router/README.md +31 -52
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +30 -53
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +9 -8
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +38 -35
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +12 -12
- package/api/@xmachines/play-solid-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-svelte/README.md +11 -26
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +12 -12
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-svelte/variables/schema.md +16 -0
- package/api/@xmachines/play-svelte-spa-router/README.md +22 -41
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-svelte-spa-router/classes/SvelteSpaRouterBridge.md +22 -21
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +3 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-svelte-spa-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterConnection.md +8 -8
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/README.md +17 -35
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-sveltekit-router/classes/SvelteKitRouterBridge.md +22 -21
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +3 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-sveltekit-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterConnection.md +8 -8
- package/api/@xmachines/play-tanstack-react-router/README.md +19 -43
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +18 -17
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +11 -8
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +16 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-tanstack-router/README.md +6 -4
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +17 -20
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +3 -3
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/README.md +26 -52
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +49 -45
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +9 -8
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-url/README.md +69 -0
- package/api/@xmachines/play-url/errors/README.md +17 -0
- package/api/@xmachines/play-url/errors/classes/InvalidBasePathError.md +200 -0
- package/api/@xmachines/play-url/errors/classes/InvalidRoutePatternError.md +203 -0
- package/api/@xmachines/play-url/errors/classes/MissingBasePathParamError.md +199 -0
- package/api/@xmachines/play-url/index/README.md +65 -0
- package/api/@xmachines/play-url/index/functions/cleanFrameworkParams.md +39 -0
- package/api/@xmachines/play-url/index/functions/getCandidates.md +29 -0
- package/api/@xmachines/play-url/index/functions/getCompiledPattern.md +31 -0
- package/api/@xmachines/play-url/index/functions/getIndexKey.md +30 -0
- package/api/@xmachines/play-url/index/functions/getNormalizedParamNameMap.md +32 -0
- package/api/@xmachines/play-url/index/functions/getPatternParamNames.md +29 -0
- package/api/@xmachines/play-url/index/functions/getRequiredPatternParamNames.md +39 -0
- package/api/@xmachines/play-url/index/functions/holdsUnsubstitutedParam.md +36 -0
- package/api/@xmachines/play-url/index/functions/isParameterizedPattern.md +36 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/joinBasePath.md +2 -2
- package/api/@xmachines/{play-router → play-url/index}/functions/normalizeBasePath.md +2 -2
- package/api/@xmachines/play-url/index/functions/normalizeParamNames.md +36 -0
- package/api/@xmachines/play-url/index/functions/parsePattern.md +27 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/pickOwnParams.md +4 -4
- package/api/@xmachines/{play-router → play-url/index}/functions/resolveBasePath.md +2 -2
- package/api/@xmachines/play-url/index/functions/resolveFrameworkParams.md +49 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/stripBasePath.md +2 -2
- package/api/@xmachines/play-url/index/interfaces/BasePathOptions.md +28 -0
- package/api/@xmachines/{play-router → play-url/index}/interfaces/FrameworkParamsSource.md +9 -9
- package/api/@xmachines/play-url/index/interfaces/GroupPart.md +15 -0
- package/api/@xmachines/play-url/index/interfaces/LiteralPart.md +14 -0
- package/api/@xmachines/play-url/index/interfaces/ParamPart.md +21 -0
- package/api/@xmachines/play-url/index/interfaces/ParsedPattern.md +23 -0
- package/api/@xmachines/play-url/index/interfaces/PatternParam.md +15 -0
- package/api/@xmachines/{play-router → play-url/index}/interfaces/ResolvedBasePath.md +6 -6
- package/api/@xmachines/play-url/index/type-aliases/PatternModifier.md +11 -0
- package/api/@xmachines/play-url/index/type-aliases/PatternPart.md +9 -0
- package/api/@xmachines/play-url/index/type-aliases/URLPatternCtor.md +22 -0
- package/api/@xmachines/play-url/index/type-aliases/URLPatternLike.md +68 -0
- package/api/@xmachines/{play-router → play-url/index}/variables/NO_BASE_PATH.md +2 -2
- package/api/@xmachines/play-url/index/variables/URLPattern.md +21 -0
- package/api/@xmachines/play-view/README.md +165 -0
- package/api/@xmachines/play-view/errors/README.md +17 -0
- package/api/@xmachines/play-view/errors/classes/ReadOnlyContextError.md +192 -0
- package/api/@xmachines/play-view/index/README.md +55 -0
- package/api/@xmachines/{play-actor → play-view/index}/functions/attachRenderErrorHandler.md +6 -6
- package/api/@xmachines/{play-actor → play-view/index}/functions/composePlayState.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/createFailureLatch.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/createReportGuard.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/createViewStoreLifecycle.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/guardContextWrites.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/refreshContextSubtree.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/reuseComposedState.md +3 -3
- package/api/@xmachines/{play-actor → play-view/index}/functions/sameViewInputs.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/toAtomState.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/typedSpec.md +2 -2
- package/api/@xmachines/play-view/index/interfaces/BaseActorProviderProps.md +49 -0
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/BaseViewContextValue.md +12 -12
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/FailureLatch.md +6 -5
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/PlaySpec.md +8 -8
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ReportGuard.md +6 -6
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ReportGuardMessages.md +6 -6
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ResolveViewStoreOptions.md +5 -5
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ViewInputs.md +7 -7
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ViewStoreLifecycle.md +6 -5
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ViewStoreResolution.md +7 -7
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/Viewable.md +5 -5
- package/api/@xmachines/play-view/index/type-aliases/ViewActor.md +26 -0
- package/api/@xmachines/{play-actor → play-view/index}/variables/CONTEXT_STATE_KEY.md +2 -2
- package/api/@xmachines/play-vue/README.md +15 -33
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +9 -9
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +11 -11
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue/variables/schema.md +71 -0
- package/api/@xmachines/play-vue-router/README.md +34 -77
- package/api/@xmachines/play-vue-router/errors/README.md +8 -0
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterNavigationError.md +193 -0
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterSendError.md +177 -0
- package/api/@xmachines/play-vue-router/index/README.md +20 -0
- package/api/@xmachines/play-vue-router/index/classes/RouteMap.md +157 -0
- package/api/@xmachines/play-vue-router/{classes → index/classes}/VueRouterBridge.md +24 -43
- package/api/@xmachines/play-vue-router/index/interfaces/PlayRouteEvent.md +130 -0
- package/api/@xmachines/play-vue-router/index/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouteMapping.md +6 -6
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouterBridge.md +5 -5
- package/api/@xmachines/play-vue-router/{variables → index/variables}/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-xstate/README.md +153 -105
- package/api/@xmachines/play-xstate/errors/README.md +13 -0
- package/api/@xmachines/play-xstate/errors/classes/ActorThrewNonErrorError.md +199 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidEventError.md +198 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidMachineError.md +169 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteHandlerError.md +197 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteMetadataError.md +176 -0
- package/api/@xmachines/play-xstate/errors/classes/MissingRouteParamError.md +199 -0
- package/api/@xmachines/play-xstate/errors/classes/MissingStateIdError.md +203 -0
- package/api/@xmachines/play-xstate/index/README.md +38 -0
- package/api/@xmachines/play-xstate/index/classes/PlayerActor.md +584 -0
- package/api/@xmachines/play-xstate/index/functions/compose.md +224 -0
- package/api/@xmachines/play-xstate/index/functions/definePlayer.md +158 -0
- package/api/@xmachines/play-xstate/index/interfaces/PlayerConfig.md +22 -0
- package/api/@xmachines/play-xstate/{interfaces → index/interfaces}/PlayerFactoryResumeOptions.md +3 -3
- package/api/@xmachines/play-xstate/{interfaces → index/interfaces}/PlayerOptions.md +8 -8
- package/api/@xmachines/play-xstate/index/type-aliases/Capability.md +33 -0
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerConstructor.md +39 -0
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerFactory.md +27 -0
- package/api/@xmachines/{play-router → play-xstate/index}/variables/DISPOSE.md +3 -3
- package/api/@xmachines/play-xstate/with-routing/README.md +46 -0
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/buildRouteUrl.md +2 -2
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/deriveRoute.md +4 -4
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/formatPlayRouteTransitions.md +2 -2
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/isAbsoluteRoute.md +3 -3
- package/api/@xmachines/play-xstate/with-routing/functions/withRouting.md +36 -0
- package/api/@xmachines/play-xstate/{interfaces → with-routing/interfaces}/RouteContext.md +6 -6
- package/api/@xmachines/play-xstate/with-routing/interfaces/RouteObject.md +34 -0
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteData.md +12 -0
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteDataResolver.md +31 -0
- package/api/@xmachines/play-xstate/{type-aliases → with-routing/type-aliases}/RouteMachineConfig.md +5 -5
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteMetadata.md +11 -0
- package/api/@xmachines/play-xstate/{type-aliases → with-routing/type-aliases}/RouteStateNode.md +21 -7
- package/api/@xmachines/play-xstate/with-view/README.md +31 -0
- package/api/@xmachines/play-xstate/with-view/functions/withView.md +32 -0
- package/api/@xmachines/shared/README.md +10 -32
- package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +2 -2
- package/api/@xmachines/shared/vitest/functions/defineXmBrowserConfig.md +1 -1
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +2 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/api/README.md +2 -0
- package/api/llms.txt +15 -10
- package/contributing/architecture.md +94 -66
- package/contributing/configuration.md +85 -26
- package/contributing/deployment.md +30 -28
- package/contributing/development.md +51 -10
- package/contributing/testing.md +87 -28
- package/examples/README.md +9 -7
- package/examples/form-validation.md +3 -2
- package/examples/multi-router-integration.md +61 -39
- package/examples/routing-patterns.md +15 -14
- package/examples/traffic-light.md +11 -5
- package/guides/README.md +1 -0
- package/guides/actor-model.md +35 -26
- package/guides/getting-started.md +49 -46
- package/guides/inspector.md +4 -4
- package/guides/routing.md +245 -0
- package/guides/state-machines.md +16 -17
- package/package.json +10 -9
- package/rfc/play.md +35 -22
- package/api/@xmachines/play-actor/classes/AbstractActor.md +0 -505
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +0 -48
- package/api/@xmachines/play-actor/interfaces/Routable.md +0 -14
- package/api/@xmachines/play-dom/type-aliases/DisposablePlayUI.md +0 -36
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-dom-router/interfaces/DisposableBrowserHistory.md +0 -262
- package/api/@xmachines/play-dom-router/interfaces/DisposableVanillaRouter.md +0 -80
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +0 -122
- package/api/@xmachines/play-react/type-aliases/PlayRendererProps.md +0 -13
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +0 -35
- package/api/@xmachines/play-router/functions/getPatternParamNames.md +0 -24
- package/api/@xmachines/play-router/functions/getRequiredPatternParamNames.md +0 -36
- package/api/@xmachines/play-router/functions/routeExists.md +0 -26
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +0 -13
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +0 -15
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +0 -17
- package/api/@xmachines/play-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +0 -135
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +0 -65
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +0 -12
- package/api/@xmachines/play-router/interfaces/RouteObject.md +0 -21
- package/api/@xmachines/play-router/interfaces/RouteTree.md +0 -21
- package/api/@xmachines/play-router/type-aliases/BaseRouteMapping.md +0 -13
- package/api/@xmachines/play-router/type-aliases/PlayRouterBridgeConstructor.md +0 -36
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +0 -11
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +0 -471
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +0 -9
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +0 -9
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +0 -29
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +0 -31
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +0 -9
- package/api/@xmachines/play-vue/variables/getPlayViewContext.md +0 -39
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +0 -135
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-vue-router/type-aliases/VueRouteMap.md +0 -13
- package/api/@xmachines/play-vue-router/variables/VueRouteMap.md +0 -13
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +0 -568
- package/api/@xmachines/play-xstate/functions/composeGuards.md +0 -86
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +0 -72
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +0 -43
- package/api/@xmachines/play-xstate/functions/definePlayer.md +0 -78
- package/api/@xmachines/play-xstate/functions/eventMatches.md +0 -45
- package/api/@xmachines/play-xstate/functions/hasContext.md +0 -45
- package/api/@xmachines/play-xstate/functions/negateGuard.md +0 -67
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +0 -20
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +0 -17
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +0 -19
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +0 -36
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +0 -23
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +0 -26
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +0 -9
package/rfc/play.md
CHANGED
|
@@ -136,10 +136,12 @@ Exports the minimal shared contracts that allow the Logic Engine and Infrastruct
|
|
|
136
136
|
|
|
137
137
|
**Role:** Abstract Logic Engine
|
|
138
138
|
|
|
139
|
-
Defines the minimal base class that all logic adapters must implement. By extending the XState `Actor` class, the `
|
|
139
|
+
Defines the minimal base class that all logic adapters must implement. By extending the XState `Actor` class, the `PlayActor` remains fully compatible with the XState ecosystem (inspection, system registration, message passing) while enforcing the Play Architecture's **push–pull signal contract**.
|
|
140
140
|
|
|
141
141
|
The base class requires only two abstract members: **reactive state** and **typed event dispatch**. Routing and view rendering are opt-in via separate interfaces, allowing actors to compose only the capabilities they need.
|
|
142
142
|
|
|
143
|
+
**Design Rationale:** The RFC declared an abstract `AbstractActor` CLASS that extended `Actor` of `xstate`, and it declared both capability interfaces in this package. The implementation made the contract an INTERFACE, `PlayActor`, because the class carried no implementation: both of its members were abstract, and its whole effect was to force the inheritance of XState on every consumer of the contract. `@xmachines/play-actor` names `xstate` nowhere now. The implementation also moved each capability interface to the package that holds its shared machinery: `Routable` is in `@xmachines/play-router`, beside the bridge that reads it, and `Viewable` and `PlaySpec` are in `@xmachines/play-view`, beside the view store lifecycle. A consumer who needs no routing and no view therefore installs neither package, and `@xmachines/play-actor` names the capability packages nowhere. The shape of each interface is unchanged.
|
|
144
|
+
|
|
143
145
|
```ts
|
|
144
146
|
import { Actor, type AnyActorLogic, type EventObject } from "xstate";
|
|
145
147
|
import type { Signal } from "@xmachines/play-signals";
|
|
@@ -170,7 +172,7 @@ export interface Viewable {
|
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
// The Base Protocol — minimal contract
|
|
173
|
-
export abstract class
|
|
175
|
+
export abstract class PlayActor<
|
|
174
176
|
TLogic extends AnyActorLogic,
|
|
175
177
|
TEvent extends EventObject = EventObject,
|
|
176
178
|
> extends Actor<TLogic> {
|
|
@@ -182,7 +184,7 @@ export abstract class AbstractActor<
|
|
|
182
184
|
}
|
|
183
185
|
```
|
|
184
186
|
|
|
185
|
-
**Design Rationale:** The original design placed `currentRoute`, `currentView`, and `catalog` directly on `
|
|
187
|
+
**Design Rationale:** The original design placed `currentRoute`, `currentView`, and `catalog` directly on `PlayActor`. The implementation extracted these into `Routable` and `Viewable` interfaces because:
|
|
186
188
|
|
|
187
189
|
1. Not all actors need routing (e.g. embedded sub-actors)
|
|
188
190
|
2. Not all actors need view rendering (e.g. background logic actors)
|
|
@@ -194,16 +196,16 @@ export abstract class AbstractActor<
|
|
|
194
196
|
|
|
195
197
|
**Role:** Concrete Logic Adapter (XState v5)
|
|
196
198
|
|
|
197
|
-
Wraps XState v5 to satisfy the `
|
|
199
|
+
Wraps XState v5 to satisfy the `PlayActor` contract. Provides the primary API for creating actors from state machine definitions.
|
|
198
200
|
|
|
199
201
|
**Primary Exports:**
|
|
200
202
|
|
|
201
203
|
- `definePlayer` — Factory builder: accepts a machine config, returns a factory function that creates `PlayerActor` instances
|
|
202
|
-
- `PlayerActor` — Concrete class extending `
|
|
204
|
+
- `PlayerActor` — Concrete class extending `PlayActor`. It carries state and send alone, and a capability mixin adds the rest
|
|
205
|
+
- `compose`, `withRouting`, `withView` — The composition of the optional capabilities onto `PlayerActor`
|
|
203
206
|
|
|
204
207
|
**Utility Exports:**
|
|
205
208
|
|
|
206
|
-
- Guard combinators: `composeGuards`, `composeGuardsOr`, `negateGuard`, `hasContext`, `eventMatches`, `contextFieldMatches`
|
|
207
209
|
- Route derivation: `deriveRoute`, `isAbsoluteRoute`, `buildRouteUrl`, `formatPlayRouteTransitions`
|
|
208
210
|
|
|
209
211
|
**Responsibilities:**
|
|
@@ -228,18 +230,22 @@ const definePlayer = <TMachine extends AnyStateMachine>(
|
|
|
228
230
|
return (input?, restore?) => new PlayerActor(machine, options, input, restore?.snapshot);
|
|
229
231
|
};
|
|
230
232
|
|
|
231
|
-
// PlayerActor
|
|
233
|
+
// PlayerActor carries the core protocol alone. It extends the actor class of XState
|
|
234
|
+
// directly, and `PlayActor` is a contract that it implements.
|
|
232
235
|
class PlayerActor<TMachine extends AnyStateMachine>
|
|
233
|
-
extends
|
|
234
|
-
implements
|
|
236
|
+
extends Actor<AnyActorLogic>
|
|
237
|
+
implements PlayActor<SnapshotFrom<TMachine>, EventFromLogic<TMachine>>
|
|
235
238
|
{
|
|
236
|
-
public state: Signal.State<
|
|
237
|
-
public currentRoute: Signal.Computed<string | null>;
|
|
238
|
-
public currentView: Signal.State<PlaySpec | null>;
|
|
239
|
-
public readonly initialRoute: string | null;
|
|
239
|
+
public state: Signal.State<SnapshotFrom<TMachine>>;
|
|
240
240
|
}
|
|
241
|
+
|
|
242
|
+
// A capability arrives through `compose`, and each one brings its own package
|
|
243
|
+
const RoutedPlayer = compose(PlayerActor, withRouting, withView);
|
|
244
|
+
// RoutedPlayer instances hold `currentRoute`, `initialRoute` and `currentView`
|
|
241
245
|
```
|
|
242
246
|
|
|
247
|
+
**Design Rationale:** The RFC made `PlayerActor` implement both capabilities directly. The implementation split them into mixins, because a direct implementation made `@xmachines/play-router` and `@xmachines/play-view` hard dependencies of every actor. Both packages are optional peer dependencies now: `definePlayer({ machine })` installs neither, `withRouting` needs `@xmachines/play-router`, and `withView` needs `@xmachines/play-view`.
|
|
248
|
+
|
|
243
249
|
**Design Rationale:** The original design passed a `catalog` to `definePlayer` and returned `{ create, catalog }`. The implementation decoupled catalogs entirely — component schemas are defined via `@xmachines/json-render-core`'s `defineCatalog` and bound to renderers via `defineRegistry`, not to actors. This means a single actor can be rendered by different component libraries without change.
|
|
244
250
|
|
|
245
251
|
### 5.3 Router Layer
|
|
@@ -250,6 +256,14 @@ class PlayerActor<TMachine extends AnyStateMachine>
|
|
|
250
256
|
|
|
251
257
|
Provides the complete routing infrastructure: route extraction from state machines, bidirectional route mapping, and the abstract `RouterBridgeBase` that all framework-specific router adapters extend.
|
|
252
258
|
|
|
259
|
+
**Design Rationale:** The RFC put the whole of the routing in one package. The implementation split it at two boundaries, because a consumer paid for both halves and used one:
|
|
260
|
+
|
|
261
|
+
- `@xmachines/play-router/xstate` holds the machine half — `extractMachineRoutes`, `createRouteMap`, `machineToGraph`, and the queries over a route tree. That half alone needs `xstate` and `@statelyai/graph`.
|
|
262
|
+
- `@xmachines/play-url` holds the URL language — the URLPattern grammar, a base path, and the params of a framework router. It knows no machine and no bridge, and BOTH directions of the routing read it.
|
|
263
|
+
- `@xmachines/play-router` keeps the route map, the match of a location, `RouterBridgeBase`, the provider lifecycle, and the `Routable` capability. It names no state machine.
|
|
264
|
+
|
|
265
|
+
The export lists below name the original layout. Each package README names what it holds now.
|
|
266
|
+
|
|
253
267
|
**Protocol Exports:**
|
|
254
268
|
|
|
255
269
|
- `RouterBridge` — Interface: `{ connect(): void; disconnect(): void }`
|
|
@@ -266,7 +280,6 @@ Provides the complete routing infrastructure: route extraction from state machin
|
|
|
266
280
|
- `extractMachineRoutes` — Build complete route tree from a machine definition
|
|
267
281
|
- `buildRouteTree` — Construct hierarchical tree from flat route info
|
|
268
282
|
- `createRouteMap` / `RouteMap` — Bidirectional path ↔ state ID resolution
|
|
269
|
-
- `BaseRouteMap` / `BaseRouteMapping` — Shared base for adapter-specific route maps
|
|
270
283
|
|
|
271
284
|
**Validation & Query Exports:**
|
|
272
285
|
|
|
@@ -284,13 +297,13 @@ Provides the complete routing infrastructure: route extraction from state machin
|
|
|
284
297
|
|
|
285
298
|
Each adapter extends `RouterBridgeBase` and implements the three abstract methods for its target router. All share the same architectural pattern:
|
|
286
299
|
|
|
287
|
-
| Package | Router
|
|
288
|
-
| --------------------------------------- |
|
|
289
|
-
| `@xmachines/play-tanstack-react-router` | TanStack Router
|
|
290
|
-
| `@xmachines/play-tanstack-solid-router` | TanStack Router
|
|
291
|
-
| `@xmachines/play-react-router` | React Router
|
|
292
|
-
| `@xmachines/play-vue-router` | Vue Router 4/5
|
|
293
|
-
| `@xmachines/play-solid-router` | SolidJS Router
|
|
300
|
+
| Package | Router | Framework |
|
|
301
|
+
| --------------------------------------- | ---------------- | --------- |
|
|
302
|
+
| `@xmachines/play-tanstack-react-router` | TanStack Router | React |
|
|
303
|
+
| `@xmachines/play-tanstack-solid-router` | TanStack Router | SolidJS |
|
|
304
|
+
| `@xmachines/play-react-router` | React Router 7/8 | React |
|
|
305
|
+
| `@xmachines/play-vue-router` | Vue Router 4/5 | Vue |
|
|
306
|
+
| `@xmachines/play-solid-router` | SolidJS Router | SolidJS |
|
|
294
307
|
|
|
295
308
|
**Runtime Adapter Responsibilities (all adapters):**
|
|
296
309
|
|
|
@@ -431,7 +444,7 @@ import { createDashboard, machine } from "./features/dashboard/player";
|
|
|
431
444
|
import { catalog } from "./catalog";
|
|
432
445
|
import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-react";
|
|
433
446
|
import { TanStackReactRouterBridge } from "@xmachines/play-tanstack-react-router";
|
|
434
|
-
import { extractMachineRoutes, createRouteMap } from "@xmachines/play-router";
|
|
447
|
+
import { extractMachineRoutes, createRouteMap } from "@xmachines/play-router/xstate";
|
|
435
448
|
|
|
436
449
|
// 1. Create the actor
|
|
437
450
|
const actor = createDashboard();
|
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
[API](../../../README.md) / [@xmachines/play-actor](../README.md) / AbstractActor
|
|
2
|
-
|
|
3
|
-
# Abstract Class: AbstractActor\<TLogic, TEvent\>
|
|
4
|
-
|
|
5
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:197](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v3.0.0/packages/play-actor/src/abstract-actor.ts#L197)
|
|
6
|
-
|
|
7
|
-
The abstract base class of an actor of the Play Architecture.
|
|
8
|
-
|
|
9
|
-
It observes the state through the signals, and it works with the tools of the
|
|
10
|
-
XState ecosystem, such as the devtools and the inspection. It also exposes the
|
|
11
|
-
reactive signals of the communication with the infrastructure layer.
|
|
12
|
-
|
|
13
|
-
**A subclass IS the actor.** Give the logic _and_ its options to
|
|
14
|
-
`super(logic, options)`, then observe `this`. A separate actor beside this
|
|
15
|
-
instance leaves this instance as an empty second actor. Every inherited member
|
|
16
|
-
then answers from that empty actor, until you forward each one: `system`,
|
|
17
|
-
`sessionId`, `clock`, the internal `_send` that receives the traffic of
|
|
18
|
-
`sendTo()`, and each member that a later XState version adds.
|
|
19
|
-
|
|
20
|
-
## Extends
|
|
21
|
-
|
|
22
|
-
- [`Actor`](https://www.jsdocs.io/package/xstate#Actor)\<`TLogic`\>
|
|
23
|
-
|
|
24
|
-
## Extended by
|
|
25
|
-
|
|
26
|
-
- [`PlayerActor`](../../play-xstate/classes/PlayerActor.md)
|
|
27
|
-
|
|
28
|
-
## Type Parameters
|
|
29
|
-
|
|
30
|
-
| Type Parameter | Default type | Description |
|
|
31
|
-
| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
32
|
-
| `TLogic` _extends_ [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | The type of the XState actor logic |
|
|
33
|
-
| `TEvent` _extends_ [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject) | [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject) | The constraint of the event type. The default is EventObject |
|
|
34
|
-
|
|
35
|
-
## Constructors
|
|
36
|
-
|
|
37
|
-
### Constructor
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
new AbstractActor<TLogic, TEvent>(logic, options?): AbstractActor<TLogic, TEvent>;
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Defined in: `xstate`
|
|
44
|
-
|
|
45
|
-
Creates a new actor instance for the given logic with the provided options,
|
|
46
|
-
if any.
|
|
47
|
-
|
|
48
|
-
#### Parameters
|
|
49
|
-
|
|
50
|
-
| Parameter | Type | Description |
|
|
51
|
-
| ---------- | ------------------------------------------------------------------------------- | --------------------------------- |
|
|
52
|
-
| `logic` | `TLogic` | The logic to create an actor from |
|
|
53
|
-
| `options?` | [`ActorOptions`](https://www.jsdocs.io/package/xstate#ActorOptions)\<`TLogic`\> | Actor options |
|
|
54
|
-
|
|
55
|
-
#### Returns
|
|
56
|
-
|
|
57
|
-
`AbstractActor`\<`TLogic`, `TEvent`\>
|
|
58
|
-
|
|
59
|
-
#### Inherited from
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
Actor<TLogic>.constructor
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Properties
|
|
66
|
-
|
|
67
|
-
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
68
|
-
| ------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
69
|
-
| <a id="property-_parent"></a> `_parent?` | `public` | [`AnyActorRef`](https://www.jsdocs.io/package/xstate#AnyActorRef) | - | `Actor._parent` | - |
|
|
70
|
-
| <a id="property-clock"></a> `clock` | `public` | [`Clock`](https://www.jsdocs.io/package/xstate#Clock) | The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions. | `Actor.clock` | - |
|
|
71
|
-
| <a id="property-id"></a> `id` | `public` | `string` | The unique identifier for this actor relative to its parent. | `Actor.id` | - |
|
|
72
|
-
| <a id="property-logic"></a> `logic` | `public` | `TLogic` | - | `Actor.logic` | - |
|
|
73
|
-
| <a id="property-options"></a> `options` | `public` | `Readonly`\<[`ActorOptions`](https://www.jsdocs.io/package/xstate#ActorOptions)\<`TLogic`\>\> | - | `Actor.options` | - |
|
|
74
|
-
| <a id="property-ref"></a> `ref` | `public` | [`ActorRef`](https://www.jsdocs.io/package/xstate#ActorRef)\<[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>, [`EventFromLogic`](https://www.jsdocs.io/package/xstate#EventFromLogic)\<`TLogic`\>, [`EmittedFrom`](https://www.jsdocs.io/package/xstate#EmittedFrom)\<`TLogic`\>\> | - | `Actor.ref` | - |
|
|
75
|
-
| <a id="property-sessionid"></a> `sessionId` | `public` | `string` | The globally unique process ID for this invocation. | `Actor.sessionId` | - |
|
|
76
|
-
| <a id="property-src"></a> `src` | `public` | \| `string` \| [`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic) | - | `Actor.src` | - |
|
|
77
|
-
| <a id="property-state"></a> `state` | `abstract` | [`State`](../../play-signals/namespaces/Signal/classes/State.md)\<`unknown`\> | The reactive snapshot of the current actor state. The infrastructure observes this signal, and it reacts to each state change. It therefore holds no coupling to the internal state machine of the actor. | - | [packages/play-actor/src/abstract-actor.ts:207](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v3.0.0/packages/play-actor/src/abstract-actor.ts#L207) |
|
|
78
|
-
| <a id="property-system"></a> `system` | `public` | [`AnyActorSystem`](https://www.jsdocs.io/package/xstate#AnyActorSystem) | The system to which this actor belongs. | `Actor.system` | - |
|
|
79
|
-
| <a id="property-systemid"></a> `systemId` | `public` | `string` \| `undefined` | - | `Actor.systemId` | - |
|
|
80
|
-
|
|
81
|
-
## Methods
|
|
82
|
-
|
|
83
|
-
### \[observable\]()
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
observable: InteropSubscribable<SnapshotFrom<TLogic>>;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Defined in: `xstate`
|
|
90
|
-
|
|
91
|
-
#### Returns
|
|
92
|
-
|
|
93
|
-
[`InteropSubscribable`](https://www.jsdocs.io/package/xstate#InteropSubscribable)\<[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>\>
|
|
94
|
-
|
|
95
|
-
#### Inherited from
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
Actor.[observable]
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
### getPersistedSnapshot()
|
|
104
|
-
|
|
105
|
-
```ts
|
|
106
|
-
getPersistedSnapshot(): Snapshot<unknown>;
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Defined in: `xstate`
|
|
110
|
-
|
|
111
|
-
Obtain the internal state of the actor, which can be persisted.
|
|
112
|
-
|
|
113
|
-
#### Returns
|
|
114
|
-
|
|
115
|
-
[`Snapshot`](https://www.jsdocs.io/package/xstate#Snapshot)\<`unknown`\>
|
|
116
|
-
|
|
117
|
-
#### Remarks
|
|
118
|
-
|
|
119
|
-
The internal state can be persisted from any actor, not only machines.
|
|
120
|
-
|
|
121
|
-
Note that the persisted state is not the same as the snapshot from
|
|
122
|
-
[Actor.getSnapshot](#getsnapshot). Persisted state represents the internal state of
|
|
123
|
-
the actor, while snapshots represent the actor's last emitted value.
|
|
124
|
-
|
|
125
|
-
Can be restored with [ActorOptions.state](https://www.jsdocs.io/package/xstate#ActorOptions.state)
|
|
126
|
-
|
|
127
|
-
#### See
|
|
128
|
-
|
|
129
|
-
https://stately.ai/docs/persistence
|
|
130
|
-
|
|
131
|
-
#### Inherited from
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
Actor.getPersistedSnapshot;
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
### getSnapshot()
|
|
140
|
-
|
|
141
|
-
```ts
|
|
142
|
-
getSnapshot(): SnapshotFrom<TLogic>;
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Defined in: `xstate`
|
|
146
|
-
|
|
147
|
-
Read an actor’s snapshot synchronously.
|
|
148
|
-
|
|
149
|
-
#### Returns
|
|
150
|
-
|
|
151
|
-
[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>
|
|
152
|
-
|
|
153
|
-
#### Remarks
|
|
154
|
-
|
|
155
|
-
The snapshot represent an actor's last emitted value.
|
|
156
|
-
|
|
157
|
-
When an actor receives an event, its internal state may change. An actor
|
|
158
|
-
may emit a snapshot when a state transition occurs.
|
|
159
|
-
|
|
160
|
-
Note that some actors, such as callback actors generated with
|
|
161
|
-
`fromCallback`, will not emit snapshots.
|
|
162
|
-
|
|
163
|
-
#### See
|
|
164
|
-
|
|
165
|
-
- [Actor.subscribe](#subscribe) to subscribe to an actor’s snapshot values.
|
|
166
|
-
- [Actor.getPersistedSnapshot](#getpersistedsnapshot) to persist the internal state of an actor (which is more than just a snapshot).
|
|
167
|
-
|
|
168
|
-
#### Inherited from
|
|
169
|
-
|
|
170
|
-
```ts
|
|
171
|
-
Actor.getSnapshot;
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
### on()
|
|
177
|
-
|
|
178
|
-
```ts
|
|
179
|
-
on<TType>(type, handler): Subscription;
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Defined in: `xstate`
|
|
183
|
-
|
|
184
|
-
#### Type Parameters
|
|
185
|
-
|
|
186
|
-
| Type Parameter |
|
|
187
|
-
| ----------------------- |
|
|
188
|
-
| `TType` _extends_ `any` |
|
|
189
|
-
|
|
190
|
-
#### Parameters
|
|
191
|
-
|
|
192
|
-
| Parameter | Type |
|
|
193
|
-
| --------- | --------------------- |
|
|
194
|
-
| `type` | `TType` |
|
|
195
|
-
| `handler` | (`emitted`) => `void` |
|
|
196
|
-
|
|
197
|
-
#### Returns
|
|
198
|
-
|
|
199
|
-
[`Subscription`](https://www.jsdocs.io/package/xstate#Subscription)
|
|
200
|
-
|
|
201
|
-
#### Inherited from
|
|
202
|
-
|
|
203
|
-
```ts
|
|
204
|
-
Actor.on;
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
### select()
|
|
210
|
-
|
|
211
|
-
```ts
|
|
212
|
-
select<TSelected>(selector, equalityFn?): Readable<TSelected>;
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
Defined in: `xstate`
|
|
216
|
-
|
|
217
|
-
#### Type Parameters
|
|
218
|
-
|
|
219
|
-
| Type Parameter |
|
|
220
|
-
| -------------- |
|
|
221
|
-
| `TSelected` |
|
|
222
|
-
|
|
223
|
-
#### Parameters
|
|
224
|
-
|
|
225
|
-
| Parameter | Type |
|
|
226
|
-
| ------------- | --------------------------- |
|
|
227
|
-
| `selector` | (`snapshot`) => `TSelected` |
|
|
228
|
-
| `equalityFn?` | (`a`, `b`) => `boolean` |
|
|
229
|
-
|
|
230
|
-
#### Returns
|
|
231
|
-
|
|
232
|
-
`Readable`\<`TSelected`\>
|
|
233
|
-
|
|
234
|
-
#### Inherited from
|
|
235
|
-
|
|
236
|
-
```ts
|
|
237
|
-
Actor.select;
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|
|
242
|
-
### send()
|
|
243
|
-
|
|
244
|
-
```ts
|
|
245
|
-
abstract send(event): void;
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Defined in: [packages/play-actor/src/abstract-actor.ts:223](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v3.0.0/packages/play-actor/src/abstract-actor.ts#L223)
|
|
249
|
-
|
|
250
|
-
Sends an event to the Actor.
|
|
251
|
-
|
|
252
|
-
The constraint is TEvent, which gives the type safety of a concrete
|
|
253
|
-
implementation.
|
|
254
|
-
|
|
255
|
-
A note for an implementation that wraps `send`, to check the event or to notify a
|
|
256
|
-
hook around it: this declaration is abstract for one reason only, to narrow the
|
|
257
|
-
event type, and TypeScript forbids a `super` call to an abstract member. Reach
|
|
258
|
-
the implementation of XState with `Actor.prototype.send.call(this, event)`
|
|
259
|
-
instead. A concrete declaration permits `super.send()`, but it also forces an
|
|
260
|
-
`override` modifier in every subclass that exists now, and that is a breaking
|
|
261
|
-
change for an adapter outside this repository.
|
|
262
|
-
|
|
263
|
-
#### Parameters
|
|
264
|
-
|
|
265
|
-
| Parameter | Type |
|
|
266
|
-
| --------- | -------- |
|
|
267
|
-
| `event` | `TEvent` |
|
|
268
|
-
|
|
269
|
-
#### Returns
|
|
270
|
-
|
|
271
|
-
`void`
|
|
272
|
-
|
|
273
|
-
#### Overrides
|
|
274
|
-
|
|
275
|
-
```ts
|
|
276
|
-
Actor.send;
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
### start()
|
|
282
|
-
|
|
283
|
-
```ts
|
|
284
|
-
start(): this;
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
Defined in: `xstate`
|
|
288
|
-
|
|
289
|
-
Starts the Actor from the initial state
|
|
290
|
-
|
|
291
|
-
#### Returns
|
|
292
|
-
|
|
293
|
-
`this`
|
|
294
|
-
|
|
295
|
-
#### Inherited from
|
|
296
|
-
|
|
297
|
-
```ts
|
|
298
|
-
Actor.start;
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
### stop()
|
|
304
|
-
|
|
305
|
-
```ts
|
|
306
|
-
stop(): this;
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Defined in: `xstate`
|
|
310
|
-
|
|
311
|
-
Stops the Actor and unsubscribe all listeners.
|
|
312
|
-
|
|
313
|
-
#### Returns
|
|
314
|
-
|
|
315
|
-
`this`
|
|
316
|
-
|
|
317
|
-
#### Inherited from
|
|
318
|
-
|
|
319
|
-
```ts
|
|
320
|
-
Actor.stop;
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
|
|
325
|
-
### subscribe()
|
|
326
|
-
|
|
327
|
-
#### Call Signature
|
|
328
|
-
|
|
329
|
-
```ts
|
|
330
|
-
subscribe(observer): Subscription;
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
Defined in: `xstate`
|
|
334
|
-
|
|
335
|
-
Subscribe an observer to an actor’s snapshot values.
|
|
336
|
-
|
|
337
|
-
##### Parameters
|
|
338
|
-
|
|
339
|
-
| Parameter | Type | Description |
|
|
340
|
-
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
341
|
-
| `observer` | [`Observer`](https://www.jsdocs.io/package/xstate#Observer)\<[`SnapshotFrom`](https://www.jsdocs.io/package/xstate#SnapshotFrom)\<`TLogic`\>\> | Either a plain function that receives the latest snapshot, or an observer object whose `.next(snapshot)` method receives the latest snapshot |
|
|
342
|
-
|
|
343
|
-
##### Returns
|
|
344
|
-
|
|
345
|
-
[`Subscription`](https://www.jsdocs.io/package/xstate#Subscription)
|
|
346
|
-
|
|
347
|
-
##### Remarks
|
|
348
|
-
|
|
349
|
-
The observer will receive the actor’s snapshot value when it is emitted.
|
|
350
|
-
The observer can be:
|
|
351
|
-
|
|
352
|
-
- A plain function that receives the latest snapshot, or
|
|
353
|
-
- An observer object whose `.next(snapshot)` method receives the latest
|
|
354
|
-
snapshot
|
|
355
|
-
|
|
356
|
-
##### Examples
|
|
357
|
-
|
|
358
|
-
```ts
|
|
359
|
-
// Observer as a plain function
|
|
360
|
-
const subscription = actor.subscribe((snapshot) => {
|
|
361
|
-
console.log(snapshot);
|
|
362
|
-
});
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
```ts
|
|
366
|
-
// Observer as an object
|
|
367
|
-
const subscription = actor.subscribe({
|
|
368
|
-
next(snapshot) {
|
|
369
|
-
console.log(snapshot);
|
|
370
|
-
},
|
|
371
|
-
error(err) {
|
|
372
|
-
// ...
|
|
373
|
-
},
|
|
374
|
-
complete() {
|
|
375
|
-
// ...
|
|
376
|
-
},
|
|
377
|
-
});
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
The return value of `actor.subscribe(observer)` is a subscription object
|
|
381
|
-
that has an `.unsubscribe()` method. You can call
|
|
382
|
-
`subscription.unsubscribe()` to unsubscribe the observer:
|
|
383
|
-
|
|
384
|
-
```ts
|
|
385
|
-
const subscription = actor.subscribe((snapshot) => {
|
|
386
|
-
// ...
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// Unsubscribe the observer
|
|
390
|
-
subscription.unsubscribe();
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
When the actor is stopped, all of its observers will automatically be
|
|
394
|
-
unsubscribed.
|
|
395
|
-
|
|
396
|
-
##### Inherited from
|
|
397
|
-
|
|
398
|
-
```ts
|
|
399
|
-
Actor.subscribe;
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
#### Call Signature
|
|
403
|
-
|
|
404
|
-
```ts
|
|
405
|
-
subscribe(
|
|
406
|
-
nextListener?,
|
|
407
|
-
errorListener?,
|
|
408
|
-
completeListener?): Subscription;
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
Defined in: `xstate`
|
|
412
|
-
|
|
413
|
-
Subscribe an observer to an actor’s snapshot values.
|
|
414
|
-
|
|
415
|
-
##### Parameters
|
|
416
|
-
|
|
417
|
-
| Parameter | Type |
|
|
418
|
-
| ------------------- | ---------------------- |
|
|
419
|
-
| `nextListener?` | (`snapshot`) => `void` |
|
|
420
|
-
| `errorListener?` | (`error`) => `void` |
|
|
421
|
-
| `completeListener?` | () => `void` |
|
|
422
|
-
|
|
423
|
-
##### Returns
|
|
424
|
-
|
|
425
|
-
[`Subscription`](https://www.jsdocs.io/package/xstate#Subscription)
|
|
426
|
-
|
|
427
|
-
##### Remarks
|
|
428
|
-
|
|
429
|
-
The observer will receive the actor’s snapshot value when it is emitted.
|
|
430
|
-
The observer can be:
|
|
431
|
-
|
|
432
|
-
- A plain function that receives the latest snapshot, or
|
|
433
|
-
- An observer object whose `.next(snapshot)` method receives the latest
|
|
434
|
-
snapshot
|
|
435
|
-
|
|
436
|
-
##### Examples
|
|
437
|
-
|
|
438
|
-
```ts
|
|
439
|
-
// Observer as a plain function
|
|
440
|
-
const subscription = actor.subscribe((snapshot) => {
|
|
441
|
-
console.log(snapshot);
|
|
442
|
-
});
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
```ts
|
|
446
|
-
// Observer as an object
|
|
447
|
-
const subscription = actor.subscribe({
|
|
448
|
-
next(snapshot) {
|
|
449
|
-
console.log(snapshot);
|
|
450
|
-
},
|
|
451
|
-
error(err) {
|
|
452
|
-
// ...
|
|
453
|
-
},
|
|
454
|
-
complete() {
|
|
455
|
-
// ...
|
|
456
|
-
},
|
|
457
|
-
});
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
The return value of `actor.subscribe(observer)` is a subscription object
|
|
461
|
-
that has an `.unsubscribe()` method. You can call
|
|
462
|
-
`subscription.unsubscribe()` to unsubscribe the observer:
|
|
463
|
-
|
|
464
|
-
```ts
|
|
465
|
-
const subscription = actor.subscribe((snapshot) => {
|
|
466
|
-
// ...
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
// Unsubscribe the observer
|
|
470
|
-
subscription.unsubscribe();
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
When the actor is stopped, all of its observers will automatically be
|
|
474
|
-
unsubscribed.
|
|
475
|
-
|
|
476
|
-
##### Inherited from
|
|
477
|
-
|
|
478
|
-
```ts
|
|
479
|
-
Actor.subscribe;
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
---
|
|
483
|
-
|
|
484
|
-
### toJSON()
|
|
485
|
-
|
|
486
|
-
```ts
|
|
487
|
-
toJSON(): object;
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
Defined in: `xstate`
|
|
491
|
-
|
|
492
|
-
#### Returns
|
|
493
|
-
|
|
494
|
-
`object`
|
|
495
|
-
|
|
496
|
-
| Name | Type | Defined in |
|
|
497
|
-
| -------------- | -------- | ---------- |
|
|
498
|
-
| `id` | `string` | - |
|
|
499
|
-
| `xstate$$type` | `number` | - |
|
|
500
|
-
|
|
501
|
-
#### Inherited from
|
|
502
|
-
|
|
503
|
-
```ts
|
|
504
|
-
Actor.toJSON;
|
|
505
|
-
```
|