Minor Changes
-
#5782
6dc2adfThanks @davidkpiano! - AddcreateSourceAtomfor 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
errorstate.const isDark = createSourceAtom({ getSnapshot: () => media.matches, subscribe: (notify) => { media.addEventListener('change', notify); return () => media.removeEventListener('change', notify); } });
Patch Changes
-
#5760
38dcaffThanks @davidkpiano! - Preserve cleared event history when checking event capabilities or evaluating transitions without committing them. Clearing storage from a subscriber no longer allows the current update to write the cleared data back.Keep newly hydrated event history after clearing an earlier log.
Persistence effects from uncommitted
store.transition(...)calls no longer write snapshot data afterclearStorage(store). ArehydrateStore(store)read that started beforeclearStorage(store)no longer restores the cleared data. -
#5760
38dcaffThanks @davidkpiano! - Fix async atoms losing their dependencies after a request succeeds or fails. Changing a dependency now reloads the value after settlement, including when a custom comparator suppresses an equivalent result.Fix writable atom updaters accidentally tracking other atoms, and deliver queued subscriber notifications before rethrowing subscriber errors.
Persist only committed updates when throttling writes. Capability checks, pure transitions, and rejected updates no longer change pending persisted data. Async storage writes now complete in event order per store.
flushStorage(store)also waits for already queued writes, including writes queued byonDone; synchronous storage remains synchronous.Preserve the latest persisted state when effects or subscriptions synchronously trigger another event. Snapshot and event persistence now retain commit order with immediate or throttled writes.
Preserve live extension state through snapshot undo/redo and custom restore events. Fix throttled persistence applying
picktwice or losing changes sent fromonDone. Report initial async storage read failures throughonError, and makeclearStoragecancel buffered writes and wait for queued writes before removing data. Withstrategy: 'event', events sent afterclearStoragestart a new history instead of rewriting the cleared one.Improve large batches of triggered events while preserving their processing and effect order.
-
#5760
38dcaffThanks @davidkpiano! -xstateis now declared as an optional peer dependency; it is only needed forfromStore().