Skip to content

Instantly share code, notes, and snippets.

@tomsseisums
Last active January 8, 2020 19:53
Show Gist options
  • Save tomsseisums/d5abe43ad951dc4b539c51fcdb61053c to your computer and use it in GitHub Desktop.
Save tomsseisums/d5abe43ad951dc4b539c51fcdb61053c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const journeyMachine = Machine({
id: "journey",
initial: "waiting-for-trip",
context: {
trip: null,
stops: null
},
states: {
"waiting-for-trip": {
on: {
TRIP_FOUND: {
target: "waiting-for-start",
cond: (context, event) => {
return event.trip && event.trip.id && event.trip.title && event.trip.stops;
},
actions: assign({
trip: (context, event) => {
return event.trip;
},
stops: (context, event) => {
return event.trip.stops;
}
})
}
}
},
"waiting-for-start": {}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment