Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Add emit support for all actor logic creators #4935

Merged
merged 4 commits into from
Jun 22, 2024

Conversation

davidkpiano
Copy link
Member

This PR adds support for emitting events from all actor logic types:

Promise actors

const logic = fromPromise(async ({ emit }) => {
  // ...
  emit({
    type: 'emitted',
    msg: 'hello'
  });
  // ...
});

Transition actors

const logic = fromTransition((state, event, { emit }) => {
  // ...
  emit({
    type: 'emitted',
    msg: 'hello'
  });
  // ...
  return state;
}, {});

Observable actors

const logic = fromObservable(({ emit }) => {
  // ...

  emit({
    type: 'emitted',
    msg: 'hello'
  });

  // ...
});

Callback actors

const logic = fromCallback(({ emit }) => {
  // ...
  emit({
    type: 'emitted',
    msg: 'hello'
  });
  // ...
});

Copy link

changeset-bot bot commented Jun 12, 2024

🦋 Changeset detected

Latest commit: 43716f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davidkpiano davidkpiano merged commit 2ac08b7 into main Jun 22, 2024
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/improve-emitted-types branch June 22, 2024 06:43
@github-actions github-actions bot mentioned this pull request Jun 22, 2024
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.

None yet

3 participants