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

Misleading docs for the guardMeta argument #1141

Closed
Ethan-Arrowood opened this issue Apr 19, 2020 · 2 comments · Fixed by #1148
Closed

Misleading docs for the guardMeta argument #1141

Ethan-Arrowood opened this issue Apr 19, 2020 · 2 comments · Fixed by #1148
Labels

Comments

@Ethan-Arrowood
Copy link

Description

In the Guards documentation section, the 3rd argument has misleading descriptions:

https://xstate.js.org/docs/guides/guards.html#guards-condition-functions

The condMeta object includes the following properties:

  • cond - the original condition object
  • state - the resolved machine state, after transition
  • _event - the SCXML event

https://xstate.js.org/docs/guides/guards.html#serializing-guards

guardMeta - an object containing meta data about the guard and transition, including:

  • cond - the original cond object
  • state - the current machine state, before transition

Is the state property the machine state after or before transition?
Or is this the different between nonserialized and serialized guard functions?

Whichever the answer is I believe the documentation should clarify.

@CodingDive
Copy link
Contributor

Nice catch. I believe the docs are wrong here.
I think a stateGuard always has the current machine state. Only when the guard evaluates to true, the transition can be taken. Therefore, the state in a guard should always be the one before the transition.

@davidkpiano
Copy link
Member

Would gladly accept a PR for this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants