@xmachines/docs 4.0.0 → 5.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 -6
- package/api/@xmachines/play/README.md +21 -21
- package/api/@xmachines/play/errors/classes/NonNullableError.md +4 -4
- package/api/@xmachines/play/errors/classes/PlayError.md +5 -4
- package/api/@xmachines/play/index/README.md +2 -2
- package/api/@xmachines/play/index/functions/asCleanup.md +4 -5
- package/api/@xmachines/play/index/functions/assertNonNullable.md +1 -1
- package/api/@xmachines/play/index/functions/shallowEqualExcept.md +1 -1
- package/api/@xmachines/play/index/type-aliases/Cleanup.md +3 -3
- package/api/@xmachines/play/index/type-aliases/DisposeKey.md +1 -1
- package/api/@xmachines/play/index/type-aliases/PlayEvent.md +2 -2
- package/api/@xmachines/play/index/variables/DISPOSE.md +1 -1
- package/api/@xmachines/play-actor/README.md +9 -9
- package/api/@xmachines/play-actor/interfaces/ActorEvent.md +2 -2
- package/api/@xmachines/play-actor/interfaces/PlayActor.md +6 -6
- package/api/@xmachines/play-atom/README.md +281 -0
- package/api/@xmachines/play-atom/functions/watchAtom.md +79 -0
- package/api/@xmachines/play-atom/interfaces/AsyncAtomOptions.md +16 -0
- package/api/@xmachines/play-atom/interfaces/Atom.md +149 -0
- package/api/@xmachines/play-atom/interfaces/AtomObserver.md +25 -0
- package/api/@xmachines/play-atom/interfaces/AtomOptions.md +33 -0
- package/api/@xmachines/play-atom/interfaces/AtomSubscription.md +23 -0
- package/api/@xmachines/play-atom/interfaces/BaseAtom.md +97 -0
- package/api/@xmachines/play-atom/interfaces/CreateAtom.md +91 -0
- package/api/@xmachines/play-atom/interfaces/Readable.md +93 -0
- package/api/@xmachines/play-atom/interfaces/ReadonlyAtom.md +108 -0
- package/api/@xmachines/play-atom/type-aliases/AnyAtom.md +13 -0
- package/api/@xmachines/play-atom/type-aliases/AsyncAtomState.md +32 -0
- package/api/@xmachines/{play-signals → play-atom}/type-aliases/Cleanup.md +4 -4
- package/api/@xmachines/play-atom/variables/createAsyncAtom.md +42 -0
- package/api/@xmachines/play-atom/variables/createAtom.md +18 -0
- package/api/@xmachines/play-atom/variables/createWritableAtom.md +70 -0
- package/api/@xmachines/play-dom/README.md +21 -17
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +10 -10
- package/api/@xmachines/play-dom/functions/asCleanup.md +4 -5
- package/api/@xmachines/play-dom/functions/createPlayUI.md +1 -1
- 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 +3 -3
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +1 -1
- package/api/@xmachines/play-dom-router/README.md +24 -24
- package/api/@xmachines/play-dom-router/classes/DomRouterBridge.md +15 -15
- package/api/@xmachines/play-dom-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-dom-router/functions/asCleanup.md +4 -5
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BasePathOptions.md +3 -7
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +15 -15
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +11 -9
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-dom-router/interfaces/RouterConnection.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +5 -5
- package/api/@xmachines/play-dom-router/type-aliases/Cleanup.md +3 -3
- package/api/@xmachines/play-dom-router/variables/DISPOSE.md +1 -1
- package/api/@xmachines/play-pattern/README.md +115 -0
- package/api/@xmachines/play-pattern/functions/buildPath.md +46 -0
- package/api/@xmachines/play-pattern/functions/createPatternCache.md +47 -0
- package/api/@xmachines/play-pattern/functions/getIndexKey.md +30 -0
- package/api/@xmachines/play-pattern/functions/isDotSegment.md +40 -0
- package/api/@xmachines/play-pattern/functions/parsePattern.md +28 -0
- package/api/@xmachines/play-pattern/interfaces/GroupPart.md +15 -0
- package/api/@xmachines/play-pattern/interfaces/LiteralPart.md +14 -0
- package/api/@xmachines/play-pattern/interfaces/ParamPart.md +21 -0
- package/api/@xmachines/play-pattern/interfaces/ParseOptions.md +19 -0
- package/api/@xmachines/play-pattern/interfaces/ParsedPattern.md +23 -0
- package/api/@xmachines/play-pattern/interfaces/PatternCache.md +65 -0
- package/api/@xmachines/play-pattern/interfaces/PatternParam.md +15 -0
- package/api/@xmachines/play-pattern/type-aliases/PathBuildResult.md +74 -0
- package/api/@xmachines/play-pattern/type-aliases/PathParams.md +15 -0
- package/api/@xmachines/play-pattern/type-aliases/PatternModifier.md +11 -0
- package/api/@xmachines/play-pattern/type-aliases/PatternPart.md +9 -0
- package/api/@xmachines/play-react/README.md +31 -21
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +6 -6
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/useAtomEffect.md +103 -0
- package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +8 -8
- 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 +8 -8
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-react/variables/ActorProvider.md +2 -2
- 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-router/README.md +3 -3
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +15 -15
- package/api/@xmachines/play-react-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +11 -9
- package/api/@xmachines/play-react-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +14 -7
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterProviderBaseProps.md +1 -1
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-router/README.md +25 -14
- package/api/@xmachines/play-router/errors/classes/DuplicateBridgeError.md +4 -4
- package/api/@xmachines/play-router/errors/classes/DuplicateRoutePathError.md +5 -5
- package/api/@xmachines/play-router/errors/classes/EmptyRoutePathError.md +5 -5
- package/api/@xmachines/play-router/errors/classes/InvalidBasePathError.md +5 -5
- package/api/@xmachines/play-router/errors/classes/InvalidRoutePatternError.md +5 -5
- package/api/@xmachines/play-router/errors/classes/InvalidStateIdError.md +5 -5
- package/api/@xmachines/play-router/errors/classes/MissingBasePathParamError.md +6 -6
- package/api/@xmachines/play-router/errors/classes/RouterSyncError.md +4 -4
- package/api/@xmachines/play-router/errors/classes/UnknownStateTypeError.md +6 -6
- package/api/@xmachines/play-router/index/README.md +10 -2
- package/api/@xmachines/play-router/index/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-router/index/classes/RouterBridgeBase.md +10 -10
- package/api/@xmachines/play-router/index/functions/buildPlayRouteEvent.md +1 -1
- package/api/@xmachines/play-router/index/functions/buildRouteTree.md +1 -1
- package/api/@xmachines/play-router/index/functions/cleanFrameworkParams.md +1 -1
- package/api/@xmachines/play-router/index/functions/createPatternCache.md +47 -0
- package/api/@xmachines/play-router/index/functions/createRouteMapFromTree.md +5 -5
- package/api/@xmachines/play-router/index/functions/createRouterConnection.md +1 -1
- package/api/@xmachines/play-router/index/functions/detectDuplicateRoutes.md +1 -1
- package/api/@xmachines/play-router/index/functions/extractQuery.md +1 -1
- package/api/@xmachines/play-router/index/functions/extractRouteParams.md +7 -6
- package/api/@xmachines/play-router/index/functions/findRouteById.md +1 -1
- package/api/@xmachines/play-router/index/functions/findRouteByPath.md +13 -6
- package/api/@xmachines/play-router/index/functions/isMountableBridge.md +1 -1
- package/api/@xmachines/play-router/index/functions/joinBasePath.md +2 -1
- package/api/@xmachines/play-router/index/functions/mountKey.md +1 -1
- package/api/@xmachines/play-router/index/functions/normalizeBasePath.md +1 -1
- package/api/@xmachines/play-router/index/functions/openProviderBridge.md +3 -3
- package/api/@xmachines/play-router/index/functions/parsePattern.md +28 -0
- package/api/@xmachines/play-router/index/functions/pickOwnParams.md +1 -1
- package/api/@xmachines/play-router/index/functions/repointProviderBridge.md +1 -1
- package/api/@xmachines/play-router/index/functions/resolveBasePath.md +1 -1
- package/api/@xmachines/play-router/index/functions/resolveFrameworkParams.md +5 -5
- package/api/@xmachines/play-router/index/functions/sanitizePathname.md +9 -24
- package/api/@xmachines/play-router/index/functions/splitLocation.md +37 -0
- package/api/@xmachines/play-router/index/functions/stripBasePath.md +1 -1
- package/api/@xmachines/play-router/index/functions/validateRouteFormat.md +1 -1
- package/api/@xmachines/play-router/index/functions/validateStateExists.md +1 -1
- package/api/@xmachines/play-router/index/interfaces/BasePathOptions.md +4 -4
- package/api/@xmachines/play-router/index/interfaces/BuildPlayRouteEventOptions.md +4 -4
- package/api/@xmachines/play-router/index/interfaces/CompileOptions.md +35 -0
- package/api/@xmachines/play-router/index/interfaces/FrameworkParamsSource.md +13 -8
- package/api/@xmachines/play-router/index/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-router/index/interfaces/MountableRouterBridge.md +9 -9
- package/api/@xmachines/play-router/index/interfaces/OpenProviderBridgeArgs.md +11 -9
- package/api/@xmachines/play-router/index/interfaces/ParseOptions.md +24 -0
- package/api/@xmachines/play-router/index/interfaces/ParsedPattern.md +23 -0
- package/api/@xmachines/play-router/index/interfaces/PatternCache.md +65 -0
- package/api/@xmachines/play-router/index/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-router/index/interfaces/PlayRouterProviderBaseProps.md +15 -9
- package/api/@xmachines/play-router/index/interfaces/ResolvedBasePath.md +3 -3
- package/api/@xmachines/play-router/index/interfaces/ResolvedRoutePath.md +3 -3
- package/api/@xmachines/play-router/index/interfaces/Routable.md +5 -5
- package/api/@xmachines/play-router/index/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/RouteInfo.md +8 -8
- package/api/@xmachines/play-router/index/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-router/index/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-router/index/interfaces/RouteMatch.md +3 -3
- package/api/@xmachines/play-router/index/interfaces/RouteNode.md +10 -10
- package/api/@xmachines/play-router/index/interfaces/RouteObject.md +5 -5
- package/api/@xmachines/play-router/index/interfaces/RouteTree.md +5 -5
- package/api/@xmachines/play-router/index/interfaces/RouteWatcherHandle.md +11 -11
- package/api/@xmachines/play-router/index/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-router/index/interfaces/RouterBridgeOptions.md +31 -0
- package/api/@xmachines/play-router/index/interfaces/RouterConnection.md +7 -7
- package/api/@xmachines/play-router/index/interfaces/SplitLocation.md +16 -0
- package/api/@xmachines/play-router/index/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-router/index/type-aliases/PlayRouterBridgeConstructor.md +14 -7
- package/api/@xmachines/play-router/index/type-aliases/RouteData.md +1 -1
- package/api/@xmachines/play-router/index/type-aliases/RouteDataResolver.md +1 -1
- package/api/@xmachines/play-router/index/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-router/index/type-aliases/URLPatternLike.md +68 -0
- package/api/@xmachines/play-router/index/variables/DISPOSE.md +1 -1
- package/api/@xmachines/play-router/index/variables/NO_BASE_PATH.md +1 -1
- package/api/@xmachines/play-router/index/variables/ROOT_NODE_ID.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/createRouteMap.md +5 -5
- package/api/@xmachines/play-router/xstate/functions/extractMachineRoutes.md +6 -5
- package/api/@xmachines/play-router/xstate/functions/getNavigableRoutes.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/getRoutableRoutes.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/getRouteMappings.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/getTransitionReachableRoutes.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/isRouteReachable.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/machineToGraph.md +1 -1
- package/api/@xmachines/play-router/xstate/functions/routeExists.md +1 -1
- package/api/@xmachines/play-router/xstate/interfaces/MachineEdgeData.md +3 -3
- package/api/@xmachines/play-router/xstate/interfaces/MachineNodeData.md +5 -5
- package/api/@xmachines/play-router/xstate/type-aliases/MachineGraph.md +1 -1
- package/api/@xmachines/play-solid/README.md +9 -5
- 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 +8 -8
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +2 -2
- 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-router/README.md +14 -14
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +18 -18
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +11 -9
- package/api/@xmachines/play-solid-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +14 -7
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterProviderBaseProps.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-svelte/README.md +11 -7
- 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 +8 -8
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +11 -11
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/README.md +14 -14
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-svelte-spa-router/classes/SvelteSpaRouterBridge.md +15 -15
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/interfaces/BasePathOptions.md +3 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +11 -9
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterConnection.md +7 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/README.md +17 -17
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-sveltekit-router/classes/SvelteKitRouterBridge.md +15 -15
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-sveltekit-router/interfaces/BasePathOptions.md +3 -7
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +15 -23
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-sveltekit-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterConnection.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/README.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +11 -11
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +11 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +14 -7
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterProviderBaseProps.md +1 -1
- 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 +1 -1
- package/api/@xmachines/play-tanstack-router/README.md +1 -1
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +16 -16
- 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 +7 -7
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +11 -11
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +11 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +14 -7
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterProviderBaseProps.md +1 -1
- 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 +1 -1
- package/api/@xmachines/play-url/README.md +21 -15
- package/api/@xmachines/play-url/errors/classes/InvalidBasePathError.md +5 -5
- package/api/@xmachines/play-url/errors/classes/InvalidRoutePatternError.md +5 -5
- package/api/@xmachines/play-url/errors/classes/MissingBasePathParamError.md +6 -6
- package/api/@xmachines/play-url/index/README.md +15 -8
- package/api/@xmachines/play-url/index/functions/buildPath.md +46 -0
- package/api/@xmachines/play-url/index/functions/cleanFrameworkParams.md +1 -1
- package/api/@xmachines/play-url/index/functions/createPatternCache.md +47 -0
- package/api/@xmachines/play-url/index/functions/getCandidates.md +1 -1
- package/api/@xmachines/play-url/index/functions/getCompiledPattern.md +8 -7
- package/api/@xmachines/play-url/index/functions/getIndexKey.md +1 -1
- package/api/@xmachines/play-url/index/functions/holdsUnsubstitutedParam.md +2 -2
- package/api/@xmachines/play-url/index/functions/isDotSegment.md +40 -0
- package/api/@xmachines/play-url/index/functions/joinBasePath.md +2 -1
- package/api/@xmachines/play-url/index/functions/normalizeBasePath.md +1 -1
- package/api/@xmachines/play-url/index/functions/parsePattern.md +6 -5
- package/api/@xmachines/play-url/index/functions/pickOwnParams.md +1 -1
- package/api/@xmachines/play-url/index/functions/resolveBasePath.md +1 -1
- package/api/@xmachines/play-url/index/functions/resolveFrameworkParams.md +5 -5
- package/api/@xmachines/play-url/index/functions/sanitizePathname.md +27 -0
- package/api/@xmachines/play-url/index/functions/splitLocation.md +37 -0
- package/api/@xmachines/play-url/index/functions/stripBasePath.md +1 -1
- package/api/@xmachines/play-url/index/interfaces/BasePathOptions.md +3 -3
- package/api/@xmachines/play-url/index/interfaces/CompileOptions.md +21 -0
- package/api/@xmachines/play-url/index/interfaces/FrameworkParamsSource.md +13 -8
- package/api/@xmachines/play-url/index/interfaces/GroupPart.md +6 -6
- package/api/@xmachines/play-url/index/interfaces/LiteralPart.md +5 -5
- package/api/@xmachines/play-url/index/interfaces/ParamPart.md +9 -9
- package/api/@xmachines/play-url/index/interfaces/ParseOptions.md +24 -0
- package/api/@xmachines/play-url/index/interfaces/ParsedPattern.md +14 -14
- package/api/@xmachines/play-url/index/interfaces/PatternCache.md +65 -0
- package/api/@xmachines/play-url/index/interfaces/PatternParam.md +6 -6
- package/api/@xmachines/play-url/index/interfaces/ResolvedBasePath.md +3 -3
- package/api/@xmachines/play-url/index/interfaces/SplitLocation.md +16 -0
- package/api/@xmachines/play-url/index/type-aliases/PathBuildResult.md +74 -0
- package/api/@xmachines/play-url/index/type-aliases/PathParams.md +15 -0
- package/api/@xmachines/play-url/index/type-aliases/PatternModifier.md +1 -1
- package/api/@xmachines/play-url/index/type-aliases/PatternPart.md +1 -1
- package/api/@xmachines/play-url/index/type-aliases/URLPatternCtor.md +1 -1
- package/api/@xmachines/play-url/index/type-aliases/URLPatternLike.md +3 -3
- package/api/@xmachines/play-url/index/variables/NO_BASE_PATH.md +1 -1
- package/api/@xmachines/play-url/index/variables/URLPattern.md +1 -1
- package/api/@xmachines/play-view/README.md +19 -8
- package/api/@xmachines/play-view/errors/classes/ReadOnlyContextError.md +5 -5
- package/api/@xmachines/play-view/index/functions/attachRenderErrorHandler.md +1 -1
- package/api/@xmachines/play-view/index/functions/composePlayState.md +1 -1
- package/api/@xmachines/play-view/index/functions/createFailureLatch.md +1 -1
- package/api/@xmachines/play-view/index/functions/createReportGuard.md +1 -1
- package/api/@xmachines/play-view/index/functions/createViewStoreLifecycle.md +1 -1
- package/api/@xmachines/play-view/index/functions/guardContextWrites.md +4 -28
- package/api/@xmachines/play-view/index/functions/refreshContextSubtree.md +1 -1
- package/api/@xmachines/play-view/index/functions/reuseComposedState.md +1 -1
- package/api/@xmachines/play-view/index/functions/sameViewInputs.md +1 -1
- package/api/@xmachines/play-view/index/functions/toAtomState.md +1 -1
- package/api/@xmachines/play-view/index/functions/typedSpec.md +1 -1
- package/api/@xmachines/play-view/index/interfaces/BaseActorProviderProps.md +5 -5
- package/api/@xmachines/play-view/index/interfaces/BaseViewContextValue.md +5 -5
- package/api/@xmachines/play-view/index/interfaces/FailureLatch.md +3 -3
- package/api/@xmachines/play-view/index/interfaces/PlaySpec.md +2 -2
- package/api/@xmachines/play-view/index/interfaces/ReportGuard.md +5 -5
- package/api/@xmachines/play-view/index/interfaces/ReportGuardMessages.md +3 -3
- package/api/@xmachines/play-view/index/interfaces/ResolveViewStoreOptions.md +2 -2
- package/api/@xmachines/play-view/index/interfaces/ViewInputs.md +4 -4
- package/api/@xmachines/play-view/index/interfaces/ViewStoreLifecycle.md +3 -3
- package/api/@xmachines/play-view/index/interfaces/ViewStoreResolution.md +4 -4
- package/api/@xmachines/play-view/index/interfaces/Viewable.md +5 -5
- package/api/@xmachines/play-view/index/type-aliases/ViewActor.md +1 -1
- package/api/@xmachines/play-view/index/variables/CONTEXT_STATE_KEY.md +1 -1
- package/api/@xmachines/play-vue/README.md +13 -9
- 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 +6 -6
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +9 -9
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +1 -1
- 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-router/README.md +12 -11
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterNavigationError.md +4 -4
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterSendError.md +4 -4
- package/api/@xmachines/play-vue-router/index/classes/RouteMap.md +11 -11
- package/api/@xmachines/play-vue-router/index/classes/VueRouterBridge.md +15 -15
- package/api/@xmachines/play-vue-router/index/interfaces/PlayRouteEvent.md +7 -7
- package/api/@xmachines/play-vue-router/index/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-vue-router/index/interfaces/RouteMapOptions.md +10 -4
- package/api/@xmachines/play-vue-router/index/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-vue-router/index/interfaces/RouterBridge.md +15 -17
- package/api/@xmachines/play-vue-router/index/variables/PlayRouterProvider.md +23 -1
- package/api/@xmachines/play-xstate/README.md +61 -30
- package/api/@xmachines/play-xstate/errors/README.md +1 -0
- package/api/@xmachines/play-xstate/errors/classes/ActorThrewNonErrorError.md +4 -4
- package/api/@xmachines/play-xstate/errors/classes/InvalidEventError.md +5 -5
- package/api/@xmachines/play-xstate/errors/classes/InvalidMachineError.md +4 -4
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteHandlerError.md +5 -5
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteMetadataError.md +5 -5
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteParamError.md +207 -0
- package/api/@xmachines/play-xstate/errors/classes/MissingRouteParamError.md +6 -6
- package/api/@xmachines/play-xstate/errors/classes/MissingStateIdError.md +6 -6
- package/api/@xmachines/play-xstate/index/README.md +2 -2
- package/api/@xmachines/play-xstate/index/classes/PlayerActor.md +41 -42
- package/api/@xmachines/play-xstate/index/functions/compose.md +4 -4
- package/api/@xmachines/play-xstate/index/functions/definePlayer.md +2 -2
- package/api/@xmachines/play-xstate/index/interfaces/PlayerConfig.md +4 -4
- package/api/@xmachines/play-xstate/index/interfaces/PlayerFactoryResumeOptions.md +2 -2
- package/api/@xmachines/play-xstate/index/interfaces/PlayerOptions.md +9 -9
- package/api/@xmachines/play-xstate/index/type-aliases/Capability.md +1 -1
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerConstructor.md +1 -1
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerFactory.md +1 -1
- package/api/@xmachines/play-xstate/index/variables/DISPOSE.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/functions/buildRouteUrl.md +13 -6
- package/api/@xmachines/play-xstate/with-routing/functions/deriveRoute.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/functions/formatPlayRouteTransitions.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/functions/isAbsoluteRoute.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/functions/withRouting.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/interfaces/RouteContext.md +5 -5
- package/api/@xmachines/play-xstate/with-routing/interfaces/RouteObject.md +5 -5
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteData.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteDataResolver.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteMachineConfig.md +4 -4
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteStateNode.md +5 -5
- package/api/@xmachines/play-xstate/with-view/functions/withView.md +6 -5
- 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 +1 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/api/README.md +2 -1
- package/api/llms.txt +4 -3
- package/contributing/architecture.md +105 -124
- package/contributing/configuration.md +15 -15
- package/contributing/deployment.md +82 -6
- package/contributing/development.md +58 -30
- package/contributing/migrating-to-play-atom.md +209 -0
- package/contributing/testing.md +61 -64
- package/examples/README.md +3 -3
- package/examples/basic-state-machine.md +4 -4
- package/examples/form-validation.md +1 -1
- package/examples/multi-router-integration.md +23 -23
- package/examples/routing-patterns.md +5 -5
- package/examples/traffic-light.md +6 -6
- package/guides/README.md +1 -1
- package/guides/actor-model.md +26 -17
- package/guides/atoms.md +264 -0
- package/guides/getting-started.md +52 -17
- package/guides/inspector.md +3 -3
- package/guides/routing.md +67 -47
- package/guides/state-machines.md +4 -4
- package/package.json +3 -3
- package/rfc/play.md +83 -52
- package/api/@xmachines/play-react/functions/useSignalEffect.md +0 -77
- package/api/@xmachines/play-router/index/functions/getPatternParamNames.md +0 -29
- package/api/@xmachines/play-router/index/functions/getRequiredPatternParamNames.md +0 -39
- package/api/@xmachines/play-signals/README.md +0 -209
- package/api/@xmachines/play-signals/functions/watchSignal.md +0 -65
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +0 -36
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +0 -49
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +0 -37
- package/api/@xmachines/play-signals/interfaces/SignalState.md +0 -68
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +0 -97
- package/api/@xmachines/play-signals/namespaces/Signal/README.md +0 -22
- package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +0 -52
- package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +0 -72
- package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/README.md +0 -21
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +0 -85
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +0 -13
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +0 -25
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +0 -9
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +0 -9
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +0 -19
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +0 -19
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +0 -33
- package/api/@xmachines/play-url/index/functions/getNormalizedParamNameMap.md +0 -32
- package/api/@xmachines/play-url/index/functions/getPatternParamNames.md +0 -29
- package/api/@xmachines/play-url/index/functions/getRequiredPatternParamNames.md +0 -39
- package/api/@xmachines/play-url/index/functions/isParameterizedPattern.md +0 -36
- package/api/@xmachines/play-url/index/functions/normalizeParamNames.md +0 -36
- package/guides/signals.md +0 -209
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
[API](../../README.md) / @xmachines/play-atom
|
|
2
|
+
|
|
3
|
+
# @xmachines/play-atom
|
|
4
|
+
|
|
5
|
+
The atom primitives for XMachines. They give the Play Architecture fine-grained reactive state. The primitives propagate state without a glitch and without a subscription of the consumer.
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-atom)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @xmachines/play-atom @xmachines/play @xstate/store
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Peer dependencies.** Install them with the package:
|
|
16
|
+
|
|
17
|
+
- [`@xmachines/play`](../play/README.md) — the core protocol. This package reads `asCleanup` and `Cleanup` from it.
|
|
18
|
+
- `@xstate/store` `^4.2.3` — the atom engine.
|
|
19
|
+
|
|
20
|
+
Install ONE copy of `@xstate/store` — see [One instance](#one-instance).
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
This package DECLARES the reactive contract of the Play Architecture, and it binds an engine to that contract in one module. The engine of today is [`@xstate/store`](https://stately.ai/docs/xstate-store), whose reactive core adapts the [Alien Signals](https://github.com/stackblitz/alien-signals) algorithm. It adds the `watchAtom` utility, which owns the subscription lifecycle, and `createWritableAtom`, which removes an overload hazard for a generic value type.
|
|
25
|
+
|
|
26
|
+
The types belong to THIS package. `Atom`, `Readable` and each name beside them are declarations here, and no forward of a type of the engine. Therefore the published `.d.ts` of a consumer names the engine never, and a change of the engine reaches this package alone.
|
|
27
|
+
|
|
28
|
+
**Import every atom in the XMachines ecosystem from this package**, and not from `@xstate/store`. One import point keeps each update and each API change in one place.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### `createAtom(value)` — writable reactive state
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { createAtom } from "@xmachines/play-atom";
|
|
36
|
+
|
|
37
|
+
const count = createAtom(0);
|
|
38
|
+
|
|
39
|
+
console.log(count.get()); // 0
|
|
40
|
+
count.set(5);
|
|
41
|
+
count.set((previous) => previous + 1);
|
|
42
|
+
console.log(count.get()); // 6
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `createAtom(fn)` — memoized derived values
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { createAtom } from "@xmachines/play-atom";
|
|
49
|
+
|
|
50
|
+
const count = createAtom(0);
|
|
51
|
+
const doubled = createAtom(() => count.get() * 2);
|
|
52
|
+
|
|
53
|
+
console.log(doubled.get()); // 0 (computed on first access)
|
|
54
|
+
count.set(5);
|
|
55
|
+
console.log(doubled.get()); // 10 (recomputed because dependency changed)
|
|
56
|
+
console.log(doubled.get()); // 10 (memoized — no recomputation)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
A computation tracks each atom that it reads. A dynamic branch is safe: the computation keeps only the atoms of the _current_ execution path as its dependencies.
|
|
60
|
+
|
|
61
|
+
The getter takes ONE parameter: the value that the atom holds already. It is `undefined` before the first derivation. Return it to keep the atom still, which stops the propagation at this atom:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const view = createAtom((previous) => {
|
|
65
|
+
const next = derive(source.get());
|
|
66
|
+
return equivalent(previous, next) ? (previous ?? null) : next;
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> A computed atom that something SUBSCRIBES to is eager. `@xstate/store` builds a subscription on an effect that reads the atom, so a write to a dependency evaluates the derivation at once, inside that write. A computed atom with no subscriber stays lazy.
|
|
71
|
+
|
|
72
|
+
### `createWritableAtom(value)` — the writable atom, with one signature
|
|
73
|
+
|
|
74
|
+
`createAtom` carries two signatures, and TypeScript must prove the argument is not a function before it reaches the writable one. For a concrete type it proves that at once. For a type parameter, or a conditional type over one, it cannot, so it picks the computed signature and returns a `ReadonlyAtom` that carries no `set`.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { createWritableAtom, type Atom } from "@xmachines/play-atom";
|
|
78
|
+
|
|
79
|
+
class Holder<T extends { value: unknown }> {
|
|
80
|
+
public readonly state: Atom<T["value"]>;
|
|
81
|
+
|
|
82
|
+
constructor(seed: T["value"]) {
|
|
83
|
+
// createAtom(seed) would give a ReadonlyAtom here.
|
|
84
|
+
this.state = createWritableAtom(seed);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `createAtom` everywhere else.
|
|
90
|
+
|
|
91
|
+
### `watchAtom` — the coalesced subscription
|
|
92
|
+
|
|
93
|
+
Use `watchAtom` to subscribe to an `Atom` or to a `ReadonlyAtom`. The callback receives the value after each change. `watchAtom` groups the updates of one synchronous batch into a single microtask.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { createAtom, watchAtom } from "@xmachines/play-atom";
|
|
97
|
+
|
|
98
|
+
const count = createAtom(0);
|
|
99
|
+
|
|
100
|
+
const cleanup = watchAtom(count, (value) => {
|
|
101
|
+
console.log("count changed:", value);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
count.set(1); // coalesced with any rapid synchronous changes
|
|
105
|
+
count.set(2);
|
|
106
|
+
count.set(3); // → logs "count changed: 3" once, from a microtask
|
|
107
|
+
|
|
108
|
+
// Stop watching
|
|
109
|
+
cleanup();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The cleanup function is idempotent. A second call is safe, and it does not throw. It is also a `Disposable`, so `using cleanup = watchAtom(...)` releases it at the end of the scope.
|
|
113
|
+
|
|
114
|
+
### `atom.subscribe` — synchronous observation
|
|
115
|
+
|
|
116
|
+
Every atom carries `subscribe`. The observer runs SYNCHRONOUSLY, inside the `set` of the atom that changed, and nothing coalesces the calls. An observer that throws therefore throws inside that `set`, and the failure lands in the code that wrote the atom. Prefer `watchAtom` unless you need the notification at the exact moment of the write.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const subscription = count.subscribe((value) => console.log(value));
|
|
120
|
+
subscription.unsubscribe();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Custom equality
|
|
124
|
+
|
|
125
|
+
`createAtom` accepts a `compare` option. It controls when an atom notifies its dependents. The default is `Object.is`.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { createAtom } from "@xmachines/play-atom";
|
|
129
|
+
import type { AtomOptions } from "@xmachines/play-atom";
|
|
130
|
+
|
|
131
|
+
const options: AtomOptions<{ name: string; age: number }> = {
|
|
132
|
+
compare: (a, b) => a.name === b.name && a.age === b.age,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const person = createAtom({ name: "Alice", age: 30 }, options);
|
|
136
|
+
// A structurally identical value does not notify the dependents
|
|
137
|
+
person.set({ name: "Alice", age: 30 });
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## One instance
|
|
141
|
+
|
|
142
|
+
`@xstate/store` holds the active subscriber in a variable of its own module. Two copies in one application build two separate graphs: a computed atom of the first copy and a subscription of the second copy never meet, the subscriber stays silent, and no error reports the fault. Every propagation of state in this architecture goes through an atom, so the second copy stops the whole reactivity of an application.
|
|
143
|
+
|
|
144
|
+
This package therefore declares `@xstate/store` as a peer dependency. A renderer declares it no more: a renderer imports the engine in no source file, and it reads the atom through this package. Bring one copy, and bring it yourself.
|
|
145
|
+
|
|
146
|
+
## API Summary
|
|
147
|
+
|
|
148
|
+
| Export | Kind | Description |
|
|
149
|
+
| ---------------------------------- | --------- | --------------------------------------------------------------------------------------------- |
|
|
150
|
+
| `createAtom(value, options?)` | function | The writable atom |
|
|
151
|
+
| `createAtom(fn, options?)` | function | The computed atom |
|
|
152
|
+
| `createWritableAtom(value, opts?)` | function | The writable atom, with one signature, for a generic value type |
|
|
153
|
+
| `createAsyncAtom(fn, options?)` | function | The computed atom of a promise. It holds an `AsyncAtomState`. `fn` reads an `AbortSignal` |
|
|
154
|
+
| `watchAtom(atom, onValue)` | function | The coalesced subscription helper. It returns a `Cleanup` |
|
|
155
|
+
| `Atom<T>` | interface | The writable atom (`.get()`, `.set()`, `.subscribe()`) |
|
|
156
|
+
| `ReadonlyAtom<T>` | interface | The computed atom (`.get()`, `.subscribe()`) |
|
|
157
|
+
| `Readable<T>` | interface | The read side of either one (`.get()`, `.subscribe()`) |
|
|
158
|
+
| `BaseAtom<T>` | interface | The common base of both kinds |
|
|
159
|
+
| `AnyAtom` | type | An atom of an unknown value type |
|
|
160
|
+
| `AtomOptions<T>` | interface | The options object of `createAtom` (`compare?`) |
|
|
161
|
+
| `AtomObserver<T>` | interface | The observer of `subscribe`, in the object form |
|
|
162
|
+
| `AtomSubscription` | interface | The release that `subscribe` returns |
|
|
163
|
+
| `AsyncAtomState<TData>` | type | The state of `createAsyncAtom`: `pending`, `done`, or `error` |
|
|
164
|
+
| `AsyncAtomOptions` | interface | What `createAsyncAtom` hands its getter: the `signal` that aborts a stale run |
|
|
165
|
+
| `CreateAtom` | interface | The two call signatures of `createAtom` |
|
|
166
|
+
| `Cleanup` | type | The release that `watchAtom` returns, re-exported from [`@xmachines/play`](../play/README.md) |
|
|
167
|
+
|
|
168
|
+
The observer types carry the `Atom` prefix on purpose: `xstate` declares `Observer` and `Subscription` too, so a plain name here would put two declarations of one name in one file. `Subscribable` stays out of the surface for the same reason.
|
|
169
|
+
|
|
170
|
+
## Migrating from `@xmachines/play-signals`
|
|
171
|
+
|
|
172
|
+
This package replaces `@xmachines/play-signals`, which wrapped the TC39 Signals polyfill. A codemod rewrites the call sites:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
curl -O https://gitlab.com/xmachin-es/xmachines-js/-/raw/main/scripts/codemod-play-atom.mjs
|
|
176
|
+
node codemod-play-atom.mjs --dry-run .
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
See [Migrating to @xmachines/play-atom](../../../contributing/migrating-to-play-atom.md) for the name table and the three behaviour changes that no codemod can make for you.
|
|
180
|
+
|
|
181
|
+
## Requirements
|
|
182
|
+
|
|
183
|
+
- **Node.js** `>= 24.0.0`
|
|
184
|
+
- **TypeScript** `5.7+` (for a consumer that uses TypeScript)
|
|
185
|
+
- **`@xstate/store`** `^4.2.3` — the atom engine, and a PEER dependency
|
|
186
|
+
|
|
187
|
+
XMachines 5.0.0 moved the engine from `@xstate/store` 3 to 4. A computed getter took a `read` helper in its first position there, and it takes the previous value alone now. Delete that first parameter:
|
|
188
|
+
|
|
189
|
+
```diff
|
|
190
|
+
-const derived = createAtom((_read, previous) => …);
|
|
191
|
+
+const derived = createAtom((previous) => …);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT — see [LICENSE](LICENSE).
|
|
197
|
+
|
|
198
|
+
The atom primitives of the XMachines Play Architecture
|
|
199
|
+
|
|
200
|
+
This package gives you the fine-grained reactive state primitives that carry every
|
|
201
|
+
value across a boundary of the Play Architecture. It keeps the reactive primitive in
|
|
202
|
+
one place, and it therefore protects the code from a change of the underlying
|
|
203
|
+
library.
|
|
204
|
+
|
|
205
|
+
**Architectural context:** the package implements **Atom-Only Reactivity (INV-03)**.
|
|
206
|
+
It gives the reactive primitives that carry the communication from the Actor to the
|
|
207
|
+
infrastructure, without a subscription of the consumer and without an event emitter.
|
|
208
|
+
Every propagation of state in the Play Architecture uses an atom, which tracks each
|
|
209
|
+
dependency and updates without a glitch.
|
|
210
|
+
|
|
211
|
+
## Example
|
|
212
|
+
|
|
213
|
+
The basic use of an atom
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { createAtom, watchAtom } from "@xmachines/play-atom";
|
|
217
|
+
|
|
218
|
+
// Create a writable atom
|
|
219
|
+
const count = createAtom(0);
|
|
220
|
+
|
|
221
|
+
// Create a computed atom
|
|
222
|
+
const doubled = createAtom(() => count.get() * 2);
|
|
223
|
+
|
|
224
|
+
// Observe the changes
|
|
225
|
+
const stop = watchAtom(doubled, (value) => {
|
|
226
|
+
console.log("Count:", count.get(), "Doubled:", value);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
count.set(5); // Logs: Count: 5 Doubled: 10
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## See
|
|
233
|
+
|
|
234
|
+
- [Play RFC](../../../rfc/play.md) - invariant INV-03
|
|
235
|
+
- [XState Store](https://stately.ai/docs/xstate-store)
|
|
236
|
+
|
|
237
|
+
## Remarks
|
|
238
|
+
|
|
239
|
+
**The engine:** the atom comes from `@xstate/store`, whose reactive core adapts the
|
|
240
|
+
Alien Signals algorithm. The algorithm resolves the diamond problem, it recomputes no
|
|
241
|
+
value that no dependency changed, and it accepts an equality function of your own
|
|
242
|
+
through the `compare` option.
|
|
243
|
+
|
|
244
|
+
**The reason for the separation:** this dedicated package DECLARES the contract, and
|
|
245
|
+
it binds the engine to that contract in one module. Therefore one place holds each
|
|
246
|
+
new version, each change of the API, and the choice of the engine itself. A consumer
|
|
247
|
+
names the engine in no import and in no manifest, so a change of the engine reaches
|
|
248
|
+
this package alone.
|
|
249
|
+
|
|
250
|
+
**`@xstate/store` is a PEER dependency, and it must resolve to ONE instance.** The
|
|
251
|
+
library holds the active subscriber in a module variable. Two copies in one
|
|
252
|
+
application track no dependency across a package boundary, and a computed atom then
|
|
253
|
+
updates never.
|
|
254
|
+
|
|
255
|
+
## Interfaces
|
|
256
|
+
|
|
257
|
+
- [AsyncAtomOptions](interfaces/AsyncAtomOptions.md)
|
|
258
|
+
- [Atom](interfaces/Atom.md)
|
|
259
|
+
- [AtomObserver](interfaces/AtomObserver.md)
|
|
260
|
+
- [AtomOptions](interfaces/AtomOptions.md)
|
|
261
|
+
- [AtomSubscription](interfaces/AtomSubscription.md)
|
|
262
|
+
- [BaseAtom](interfaces/BaseAtom.md)
|
|
263
|
+
- [CreateAtom](interfaces/CreateAtom.md)
|
|
264
|
+
- [Readable](interfaces/Readable.md)
|
|
265
|
+
- [ReadonlyAtom](interfaces/ReadonlyAtom.md)
|
|
266
|
+
|
|
267
|
+
## Type Aliases
|
|
268
|
+
|
|
269
|
+
- [AnyAtom](type-aliases/AnyAtom.md)
|
|
270
|
+
- [AsyncAtomState](type-aliases/AsyncAtomState.md)
|
|
271
|
+
- [Cleanup](type-aliases/Cleanup.md)
|
|
272
|
+
|
|
273
|
+
## Variables
|
|
274
|
+
|
|
275
|
+
- [createAsyncAtom](variables/createAsyncAtom.md)
|
|
276
|
+
- [createAtom](variables/createAtom.md)
|
|
277
|
+
- [createWritableAtom](variables/createWritableAtom.md)
|
|
278
|
+
|
|
279
|
+
## Functions
|
|
280
|
+
|
|
281
|
+
- [watchAtom](functions/watchAtom.md)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / watchAtom
|
|
2
|
+
|
|
3
|
+
# Function: watchAtom()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function watchAtom<T>(atom, onValue): Cleanup;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [play-atom/src/watch-atom.ts:58](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/watch-atom.ts#L58)
|
|
10
|
+
|
|
11
|
+
Subscribes to one atom, and coalesces the notifications into one microtask.
|
|
12
|
+
|
|
13
|
+
`@xstate/store` notifies an observer SYNCHRONOUSLY from `set`. This function keeps
|
|
14
|
+
that notification, and it defers the callback to a microtask. One batch of
|
|
15
|
+
synchronous writes therefore calls the callback one time, with the last value. The
|
|
16
|
+
cleanup function is idempotent.
|
|
17
|
+
|
|
18
|
+
**The lifecycle:**
|
|
19
|
+
|
|
20
|
+
- The `disposed` flag stops a callback after the cleanup: the microtask returns at
|
|
21
|
+
once when the cleanup runs before the microtask fires.
|
|
22
|
+
- The `scheduled` guard removes the duplicates of rapid synchronous writes: one
|
|
23
|
+
batch of synchronous writes queues one microtask only.
|
|
24
|
+
- The guard clears BEFORE the callback, and not after it. A callback that WRITES the
|
|
25
|
+
atom that it watches therefore schedules the next delivery, and it reaches the
|
|
26
|
+
caller with the value that it wrote. A callback that THROWS keeps the watch,
|
|
27
|
+
because the throw leaves the microtask and never reaches the subscription.
|
|
28
|
+
|
|
29
|
+
The library owns the dependency edges. `@xstate/store` builds the subscription on an
|
|
30
|
+
effect, and the effect holds ONE edge to the atom for the life of the watch. A caller
|
|
31
|
+
therefore arms the watch one time, and no call site of this function counts emissions
|
|
32
|
+
or re-arms anything.
|
|
33
|
+
|
|
34
|
+
A CAUTION for a callback that writes the atom that it watches: the write reaches the
|
|
35
|
+
callback, so a callback that writes a NEW value on every call runs again for ever,
|
|
36
|
+
and the microtask queue drains never. That is the loop of the caller, and this
|
|
37
|
+
function bounds it not. A write of the SAME value ends the sequence by itself,
|
|
38
|
+
because an atom notifies for a value that it holds already never.
|
|
39
|
+
|
|
40
|
+
The return is a [Cleanup](../type-aliases/Cleanup.md): a function, and a `Disposable`. A caller that keeps
|
|
41
|
+
the release in a field and runs it from a teardown keeps that code. A caller inside
|
|
42
|
+
one scope writes `using` and writes no teardown:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
using stop = watchAtom(count, render);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Type Parameters
|
|
49
|
+
|
|
50
|
+
| Type Parameter |
|
|
51
|
+
| -------------- |
|
|
52
|
+
| `T` |
|
|
53
|
+
|
|
54
|
+
## Parameters
|
|
55
|
+
|
|
56
|
+
| Parameter | Type | Description |
|
|
57
|
+
| --------- | ---------------------------------------------- | ------------------------------------------------------------ |
|
|
58
|
+
| `atom` | [`Readable`](../interfaces/Readable.md)\<`T`\> | The `Atom` or the `ReadonlyAtom` to subscribe to. |
|
|
59
|
+
| `onValue` | (`value`) => `void` | The function reads the current atom value after each change. |
|
|
60
|
+
|
|
61
|
+
## Returns
|
|
62
|
+
|
|
63
|
+
[`Cleanup`](../type-aliases/Cleanup.md)
|
|
64
|
+
|
|
65
|
+
The release. It removes the subscription.
|
|
66
|
+
|
|
67
|
+
## Example
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { createAtom, watchAtom } from "@xmachines/play-atom";
|
|
71
|
+
|
|
72
|
+
const count = createAtom(0);
|
|
73
|
+
const stop = watchAtom(count, (value) => console.log(value));
|
|
74
|
+
|
|
75
|
+
count.set(1);
|
|
76
|
+
count.set(2); // One microtask, and the callback reads 2 one time.
|
|
77
|
+
|
|
78
|
+
stop();
|
|
79
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / AsyncAtomOptions
|
|
2
|
+
|
|
3
|
+
# Interface: AsyncAtomOptions
|
|
4
|
+
|
|
5
|
+
Defined in: [play-atom/src/types.ts:168](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L168)
|
|
6
|
+
|
|
7
|
+
What `createAsyncAtom` gives its getter
|
|
8
|
+
|
|
9
|
+
The engine aborts the signal when the atom derives again before the run settles, so a
|
|
10
|
+
stale answer reaches the atom never. Pass it to `fetch`, and the request stops with it.
|
|
11
|
+
|
|
12
|
+
## Properties
|
|
13
|
+
|
|
14
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
15
|
+
| ------------------------------------- | ---------- | ------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
+
| <a id="property-signal"></a> `signal` | `readonly` | `AbortSignal` | Aborted when the atom derives again before this run settles. | [play-atom/src/types.ts:170](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L170) |
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / Atom
|
|
2
|
+
|
|
3
|
+
# Interface: Atom\<T\>
|
|
4
|
+
|
|
5
|
+
Defined in: [play-atom/src/types.ts:117](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L117)
|
|
6
|
+
|
|
7
|
+
The writable atom. It holds one reactive value
|
|
8
|
+
|
|
9
|
+
A `get()` call inside a computed atom or inside a subscription tracks the atom as a
|
|
10
|
+
dependency. A `set()` call notifies every computation and every observer that
|
|
11
|
+
depends on the atom. `set` accepts a value, and it accepts a function of the
|
|
12
|
+
previous value.
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { createAtom } from "@xmachines/play-atom";
|
|
18
|
+
|
|
19
|
+
const name = createAtom("Alice");
|
|
20
|
+
console.log(name.get()); // "Alice"
|
|
21
|
+
name.set("Bob");
|
|
22
|
+
name.set((previous) => previous.toUpperCase()); // "BOB"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Extends
|
|
26
|
+
|
|
27
|
+
- [`BaseAtom`](BaseAtom.md)\<`T`\>
|
|
28
|
+
|
|
29
|
+
## Type Parameters
|
|
30
|
+
|
|
31
|
+
| Type Parameter |
|
|
32
|
+
| -------------- |
|
|
33
|
+
| `T` |
|
|
34
|
+
|
|
35
|
+
## Methods
|
|
36
|
+
|
|
37
|
+
### get()
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
get(): T;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Defined in: [play-atom/src/types.ts:59](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L59)
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`T`
|
|
48
|
+
|
|
49
|
+
#### Inherited from
|
|
50
|
+
|
|
51
|
+
[`BaseAtom`](BaseAtom.md).[`get`](BaseAtom.md#get)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### set()
|
|
56
|
+
|
|
57
|
+
#### Call Signature
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
set(fn): void;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Defined in: [play-atom/src/types.ts:119](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L119)
|
|
64
|
+
|
|
65
|
+
Sets the value of the atom from the previous value.
|
|
66
|
+
|
|
67
|
+
##### Parameters
|
|
68
|
+
|
|
69
|
+
| Parameter | Type |
|
|
70
|
+
| --------- | ------------------- |
|
|
71
|
+
| `fn` | (`previous`) => `T` |
|
|
72
|
+
|
|
73
|
+
##### Returns
|
|
74
|
+
|
|
75
|
+
`void`
|
|
76
|
+
|
|
77
|
+
#### Call Signature
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
set(value): void;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Defined in: [play-atom/src/types.ts:121](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L121)
|
|
84
|
+
|
|
85
|
+
Sets the value of the atom.
|
|
86
|
+
|
|
87
|
+
##### Parameters
|
|
88
|
+
|
|
89
|
+
| Parameter | Type |
|
|
90
|
+
| --------- | ---- |
|
|
91
|
+
| `value` | `T` |
|
|
92
|
+
|
|
93
|
+
##### Returns
|
|
94
|
+
|
|
95
|
+
`void`
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### subscribe()
|
|
100
|
+
|
|
101
|
+
#### Call Signature
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
subscribe(observer): AtomSubscription;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Defined in: [play-atom/src/types.ts:60](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L60)
|
|
108
|
+
|
|
109
|
+
##### Parameters
|
|
110
|
+
|
|
111
|
+
| Parameter | Type |
|
|
112
|
+
| ---------- | ---------------------------------------- |
|
|
113
|
+
| `observer` | [`AtomObserver`](AtomObserver.md)\<`T`\> |
|
|
114
|
+
|
|
115
|
+
##### Returns
|
|
116
|
+
|
|
117
|
+
[`AtomSubscription`](AtomSubscription.md)
|
|
118
|
+
|
|
119
|
+
##### Inherited from
|
|
120
|
+
|
|
121
|
+
[`BaseAtom`](BaseAtom.md).[`subscribe`](BaseAtom.md#subscribe)
|
|
122
|
+
|
|
123
|
+
#### Call Signature
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
subscribe(
|
|
127
|
+
next,
|
|
128
|
+
error?,
|
|
129
|
+
complete?
|
|
130
|
+
): AtomSubscription;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Defined in: [play-atom/src/types.ts:61](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L61)
|
|
134
|
+
|
|
135
|
+
##### Parameters
|
|
136
|
+
|
|
137
|
+
| Parameter | Type |
|
|
138
|
+
| ----------- | ------------------- |
|
|
139
|
+
| `next` | (`value`) => `void` |
|
|
140
|
+
| `error?` | (`error`) => `void` |
|
|
141
|
+
| `complete?` | () => `void` |
|
|
142
|
+
|
|
143
|
+
##### Returns
|
|
144
|
+
|
|
145
|
+
[`AtomSubscription`](AtomSubscription.md)
|
|
146
|
+
|
|
147
|
+
##### Inherited from
|
|
148
|
+
|
|
149
|
+
[`BaseAtom`](BaseAtom.md).[`subscribe`](BaseAtom.md#subscribe)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / AtomObserver
|
|
2
|
+
|
|
3
|
+
# Interface: AtomObserver\<T\>
|
|
4
|
+
|
|
5
|
+
Defined in: [play-atom/src/types.ts:34](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L34)
|
|
6
|
+
|
|
7
|
+
The observer of an atom, in the object form
|
|
8
|
+
|
|
9
|
+
Each member is optional, so an observer of the value alone gives `next` alone. An
|
|
10
|
+
atom completes never and it fails never, so `error` and `complete` stay for the
|
|
11
|
+
consumers that adapt an atom to an observable.
|
|
12
|
+
|
|
13
|
+
## Type Parameters
|
|
14
|
+
|
|
15
|
+
| Type Parameter |
|
|
16
|
+
| -------------- |
|
|
17
|
+
| `T` |
|
|
18
|
+
|
|
19
|
+
## Properties
|
|
20
|
+
|
|
21
|
+
| Property | Type | Defined in |
|
|
22
|
+
| ------------------------------------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| <a id="property-complete"></a> `complete?` | () => `void` | [play-atom/src/types.ts:37](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L37) |
|
|
24
|
+
| <a id="property-error"></a> `error?` | (`error`) => `void` | [play-atom/src/types.ts:36](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L36) |
|
|
25
|
+
| <a id="property-next"></a> `next?` | (`value`) => `void` | [play-atom/src/types.ts:35](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L35) |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / AtomOptions
|
|
2
|
+
|
|
3
|
+
# Interface: AtomOptions\<T\>
|
|
4
|
+
|
|
5
|
+
Defined in: [play-atom/src/types.ts:147](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L147)
|
|
6
|
+
|
|
7
|
+
The options of `createAtom`
|
|
8
|
+
|
|
9
|
+
`compare` decides if the value changed. The default is `Object.is`. An atom that
|
|
10
|
+
compares equal notifies no observer.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { createAtom } from "@xmachines/play-atom";
|
|
16
|
+
|
|
17
|
+
const point = createAtom(
|
|
18
|
+
{ x: 0, y: 0 },
|
|
19
|
+
{ compare: (previous, next) => previous.x === next.x && previous.y === next.y },
|
|
20
|
+
);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
|
|
25
|
+
| Type Parameter |
|
|
26
|
+
| -------------- |
|
|
27
|
+
| `T` |
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
| Property | Type | Defined in |
|
|
32
|
+
| ---------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| <a id="property-compare"></a> `compare?` | (`previous`, `next`) => `boolean` | [play-atom/src/types.ts:148](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L148) |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-atom](../README.md) / AtomSubscription
|
|
2
|
+
|
|
3
|
+
# Interface: AtomSubscription
|
|
4
|
+
|
|
5
|
+
Defined in: [play-atom/src/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L23)
|
|
6
|
+
|
|
7
|
+
The release of one subscription
|
|
8
|
+
|
|
9
|
+
`subscribe` returns it. Call `unsubscribe` one time. A second call does nothing.
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
### unsubscribe()
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
unsubscribe(): void;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Defined in: [play-atom/src/types.ts:24](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v5.0.0/packages/play-atom/src/types.ts#L24)
|
|
20
|
+
|
|
21
|
+
#### Returns
|
|
22
|
+
|
|
23
|
+
`void`
|