Skip to content

Instantly share code, notes, and snippets.

@twelch
Created January 23, 2020 01:39
Show Gist options
  • Save twelch/098824dc85f09e131376445efec58a02 to your computer and use it in GitHub Desktop.
Save twelch/098824dc85f09e131376445efec58a02 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 fetchMachine = Machine({
id: 'fetch',
initial: 'inactive',
states: {
inactive: {
on: {
REGISTER: 'removed'
}
},
removed: {
on: {
DEREGISTER: 'inactive',
SERVICE_START: 'available'
}
},
available: {
on: {
SERVICE_END: 'removed',
AVAILABLE_LEAVE: 'elsewhere',
TRIP_START: 'trip',
RESERVE: 'reserved'
}
},
elsewhere: {
on: {
SERVICE_START: 'available',
RESERVE_ENTER: 'reserved',
TRIP_ENTER: 'trip',
DEREGISTER: 'inactive'
}
},
trip: {
on: {
TRIP_LEAVE: 'elsewhere',
TRIP_END: 'available',
TRIP_STOP: 'stopped'
}
},
stopped: {
on: {
TRIP_RESUME: 'trip',
TRIP_START: 'trip',
}
},
reserved: {
on: {
CANCEL_RESERVATION: 'available',
RESERVE_STOP: 'stopped',
RESERVE_LEAVE: 'elsewhere',
TRIP_START: 'trip'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment