Created
February 24, 2020 16:58
-
-
Save vladimir-e/fdf62709b0c29479b03e3aafed49cae8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const rideMachine = Machine({ | |
id: 'customer ride', | |
initial: 'new', | |
context: { | |
max_time: 5000 | |
}, | |
states: { | |
new: { | |
on: { | |
CREATE: 'visible' | |
} | |
}, | |
visible: { | |
on: { | |
DRIVER_ACCEPTED: 'booked', | |
CANCELLED: 'new', | |
TIMEOUT: 'new' | |
} | |
}, | |
'booked': { | |
on: { | |
DRIVER_ARRIVES: 'in-progress' | |
} | |
}, | |
'in-progress': { | |
on: { | |
DESTINATION_REACHED: 'payment_due', | |
ADD_STOP: 'in-progress' | |
} | |
}, | |
payment_due: { | |
on: { | |
PAID: 'completed', | |
} | |
}, | |
'completed': { | |
type: 'final' | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment