github statelyai/xstate @xstate/store@0.0.2

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
7 months ago

Patch Changes

  • #4752 8a32374e7 Thanks @davidkpiano! - Initial release of @xstate/store

    import { createStore } from '@xstate/store';
    
    const store = createStore(
      // initial context
      { count: 0, greeting: 'hello' },
      // transitions
      {
        inc: {
          count: (context) => context.count + 1
        },
        updateBoth: {
          count: () => 42,
          greeting: 'hi'
        }
      }
    );
    
    store.send({
      type: 'inc'
    });
    
    console.log(store.getSnapshot());
    // Logs:
    // {
    //   status: 'active',
    //   context: {
    //     count: 1,
    //     greeting: 'hello'
    //   }
    // }

Don't miss a new xstate release

NewReleases is sending notifications on new releases.