Skip to content

Comments

Version Packages#5468

Open
github-actions[bot] wants to merge 1 commit intomainfrom
changeset-release/main
Open

Version Packages#5468
github-actions[bot] wants to merge 1 commit intomainfrom
changeset-release/main

Conversation

@github-actions
Copy link
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@xstate/store@3.16.0

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 }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants