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

[v5] createEmptyActor() #3968

Merged
merged 7 commits into from
Apr 20, 2023
Merged

[v5] createEmptyActor() #3968

merged 7 commits into from
Apr 20, 2023

Conversation

davidkpiano
Copy link
Member

@davidkpiano davidkpiano commented Apr 15, 2023

This PR makes it easy to create null actors which only emit undefined.

Especially in @xstate/react, this makes working with maybe-undefined actors easier:

import { createEmptyActor } from 'xstate/actors';

// ...
function Comp({ maybeActor }) {
  const [state, send] = useActor(maybeActor ?? createEmptyActor());

  state?.count; // strongly-typed; state can be undefined
}

@changeset-bot
Copy link

changeset-bot bot commented Apr 15, 2023

🦋 Changeset detected

Latest commit: c03ee88

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

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

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 15, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c03ee88:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

@ghost
Copy link

ghost commented Apr 15, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@davidkpiano
Copy link
Member Author

Addresses #1416

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@davidkpiano davidkpiano changed the title [v5] createNullActor() [v5] createEmptyActor() Apr 20, 2023
davidkpiano and others added 3 commits April 20, 2023 07:35
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@Andarist Andarist merged commit eecb31b into next Apr 20, 2023
@Andarist Andarist deleted the v5/null-actor branch April 20, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants