-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Trivia Game App to examples #4898
Add Trivia Game App to examples #4898
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny suggestion - may be better to put this directly in src/
for easier discoverability (flattening file structure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
}, | ||
guards: { | ||
isAnswerCorrect: ({context, event}) => { | ||
if(event.type !== "user.selectAnswer") return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: better to use params
as a future refactor item, but for now, since we're only expecting the guard to be called in one place:
if(event.type !== "user.selectAnswer") return false | |
assertEvent(event, 'user.selectAnswer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Yeah, the use of params
is actually much better to not depend on the machine context.
Thanks for the suggestion of assertEvent
, missed it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very awesome! Just some small nits.
Thanks for the review @davidkpiano ! I have updated the PR |
This is a trivia game app made using XState v5. The purpose is to give users an example of how to use the different functionality, methods and properties of actors and state machines.