Skip to content

@xstate/store@0.0.2

Compare
Choose a tag to compare
@github-actions github-actions released this 07 Apr 13:21
· 25 commits to main since this release
158eca6

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'
    //   }
    // }