Skip to main content
Storage emits four event types and exposes subscription helpers for React useSyncExternalStore.

Event types

on / off

Event listeners are in-process only. Cross-tab invalidation uses the cache bus, not these callbacks.

React subscriptions

subscribe and subscribeAll notify useSyncExternalStore without exposing values in the callback (read via getSnapshot instead).
@brushy/storage-react wires these internally; you rarely call them directly unless building custom hooks.

Remote invalidation events

When a cache bus delivers remote events, the instance:
  • del / expired: removes the key from memory and persist, notifies subscribers
  • flush: clears all keys
  • set: drops the in-memory copy (invalidates without replicating the remote value)
This keeps tabs and runtimes consistent without broadcasting full payloads by default.