Skip to content

Releases: statelyai/xstate

@xstate/[email protected]

17 Oct 11:49
b730b29
Compare
Choose a tag to compare

Patch Changes

[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

Patch Changes

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

Minor Changes

  • #5079 25963966c394fc904dc9b701a420b6e204ebe7f7 Thanks @davidkpiano! - The createStoreWithProducer(…) function now uses the new configuration API:

    import { createStoreWithProducer } from '@xstate/store';
    // DEPRECATED API
    // const store = createStoreWithProducer(
    //   producer,
    //   {
    //     count: 0
    //   },
    //   {
    //     inc: (context, event) => {
    //       context.count++;
    //     }
    //   }
    // );
    
    const store = createStoreWithProducer(producer, {
      context: {
        count: 0
      },
      on: {
        inc: (context, event) => {
          context.count++;
        }
      }
    });

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

@xstate/[email protected]

21 Sep 06:54
fe91f9e
Compare
Choose a tag to compare

@xstate/[email protected]

18 Sep 16:25
de6591f
Compare
Choose a tag to compare

Minor Changes

  • #5085 51437a4d036029ab4ff74cb52721178b3e525c48 Thanks @davidkpiano! - The shallowEqual comparator has been added for selector comparison:

    import { shallowEqual } from '@xstate/store';
    import { useSelector } from '@xstate/store/react';
    
    import { store } from './store';
    
    function MyComponent() {
      const state = useSelector(
        store,
        (s) => {
          return s.items.filter(/* ... */);
        },
        shallowEqual
      );
    
      // ...
    }

@xstate/[email protected]

16 Sep 15:08
571e266
Compare
Choose a tag to compare

Minor Changes

  • #5064 84aca37d0b02cb9cd5a32c8fd09e487bd8fe2a47 Thanks @davidkpiano! - There is a new single-argument config API for createStore(config):

    const store = createStore({
      // Types (optional)
      types: {
        emitted: {} as { type: 'incremented' }
      },
    
      // Context
      context: { count: 0 },
    
      // Transitions
      on: {
        inc: (context, event: { by: number }, enq) => {
          enq.emit({ type: 'incremented' });
    
          return { count: context.count + event.by };
        },
        dec: (context, event: { by: number }) => ({
          count: context.count - event.by
        })
      }
    });
  • #5064 84aca37d0b02cb9cd5a32c8fd09e487bd8fe2a47 Thanks @davidkpiano! - You can now emit events from a store:

    import { createStore } from '@xstate/store';
    
    const store = createStore({
      context: {
        count: 0
      },
      on: {
        increment: (context, event, { emit }) => {
          emit({ type: 'incremented' });
          return { count: context.count + 1 };
        }
      }
    });
    
    store.on('incremented', () => {
      console.log('incremented!');
    });