Skip to content

@xstate/store@5.0.0-alpha.6

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 08 Oct 21:29
· 12 commits to main since this release
ac890f2

Minor Changes

  • 73cff29: Add createSourceAtom for read-only external snapshots. Direct and derived subscribers share one listener, released when the last consumer leaves. Plain reads do not subscribe; reconnecting refreshes the snapshot. The source adapter can return a cleanup function or a { unsubscribe() } subscription. Public atom subscriptions always return { unsubscribe() }, matching existing XState subscriptions.

    Failed activation remains eligible for a later atom operation. Errors delivering an async atom result are exposed through its error state.

    const isDark = createSourceAtom({
      getSnapshot: () => media.matches,
      subscribe: (notify) => {
        media.addEventListener('change', notify);
        return () => media.removeEventListener('change', notify);
      }
    });