github statelyai/xstate @xstate/store@3.16.0

9 hours ago

Minor Changes

  • #5467 d54cc47 Thanks @davidkpiano! - Add wildcard '*' support for store.on('*', …) to listen to all emitted events. The handler receives the union of all emitted event types.

    const store = createStore({
      context: { count: 0 },
      emits: {
        increased: (_: { upBy: number }) => {},
        decreased: (_: { downBy: number }) => {}
      },
      on: {
        inc: (ctx, _, enq) => {
          enq.emit.increased({ upBy: 1 });
          return { ...ctx, count: ctx.count + 1 };
        }
      }
    });
    
    store.on('*', (ev) => {
      // ev:
      // | { type: 'increased'; upBy: number }
      // | { type: 'decreased'; downBy: number }
    });

Don't miss a new xstate release

NewReleases is sending notifications on new releases.