Welcome to my workshop on State Machines and the XState library. I'm really excited to have the opportunity to share this topic with you and help you learn it.
In order to maximize your experience of the workshop, please do the following before the workshop starts:
You will also need either a:
npm
or yarn
- so you can install the packages and run the code in this repositoryOr:
If you would like to have local access to the code and to follow along, I recommend forking this repo. If you do fork this repo, be sure to run npm install
or yarn install
from the root directory. This will enable you to run any tests to verify your work.
If you are working on a section or a challenge, you can easily run the tests for that section alone by changing to the correct directory and either running npm run test
or yarn run test
. You may also run the tests in watch
mode by running npm run test:watch
or yarn run test:watch
config
createMachine
transition(state, event)
interpret
er
currentState()
start
, stop
, and send
subscribe(listener)
toStateObject(state)
state.changed
toTransitionObject(transition)
actions = []
and return it in our state objectsevent
as an argument to our actionstoEventObject(event)
actions
in send
concat
entry with actions
concat
exit with actions
and entry
entry
actions
toArray
helpertoActionObject
send
to use exec
context
to our configCHANGE_COLOR
eventassign(context, event)
action object factory
assign
assign
actionsassign
gotchas and unexpected resultschanged
if assigned
context
to our actions
cond
from transition objectcond(context, event)