github statelyai/xstate @xstate/store@3.14.0

23 hours ago

Minor Changes

  • #5427 77ec4ad Thanks @davidkpiano! - Add .with() method for store extensions.

    import { createStore } from '@xstate/store';
    import { undoRedo } from '@xstate/store/undo';
    
    const store = createStore({
      context: { count: 0 },
      on: {
        inc: (ctx) => ({ count: ctx.count + 1 }),
        dec: (ctx) => ({ count: ctx.count - 1 })
      }
    }).with(undoRedo());
    
    store.trigger.inc(); // count = 1
    
    // Added from the undoRedo extension
    store.trigger.undo(); // count = 0
    store.trigger.redo(); // count = 1

Don't miss a new xstate release

NewReleases is sending notifications on new releases.