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

Version Packages #2634

Merged
merged 1 commit into from
Sep 14, 2021
Merged

Version Packages #2634

merged 1 commit into from
Sep 14, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 10, 2021

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@4.24.0

Minor Changes

  • #2546 a4cfce18c Thanks @davidkpiano! - You can now know if an event will cause a state change by using the new state.can(event) method, which will return true if an interpreted machine will "change" the state when sent the event, or false otherwise:

    const machine = createMachine({
      initial: 'inactive',
      states: {
        inactive: {
          on: {
            TOGGLE: 'active'
          }
        },
        active: {
          on: {
            DO_SOMETHING: { actions: ['something'] }
          }
        }
      }
    });
    
    const state = machine.initialState;
    
    state.can('TOGGLE'); // true
    state.can('DO_SOMETHING'); // false
    
    // Also takes in full event objects:
    state.can({
      type: 'DO_SOMETHING',
      data: 42
    }); // false

    A state is considered "changed" if any of the following are true:

    • its state.value changes
    • there are new state.actions to be executed
    • its state.context changes

    See state.changed (documentation) for more details.

Patch Changes

  • #2632 f8cf5dfe0 Thanks @davidkpiano! - A regression was fixed where actions were being typed as never if events were specified in createModel(...) but not actions:

    const model = createModel(
      {},
      {
        events: {}
      }
    );
    
    model.createMachine({
      // These actions will cause TS to not compile
      entry: 'someAction',
      exit: { type: 'someObjectAction' }
    });

@davidkpiano davidkpiano merged commit 9bf5b15 into main Sep 14, 2021
@davidkpiano davidkpiano deleted the changeset-release/main branch September 14, 2021 17:51
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

1 participant