Skip to content

Instantly share code, notes, and snippets.

@twelch
Created February 15, 2020 18:19
Show Gist options
  • Save twelch/b2b2270febede69be6f02955e07770aa to your computer and use it in GitHub Desktop.
Save twelch/b2b2270febede69be6f02955e07770aa to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// MDS Micromobility state machine
// 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',
TRIP_ENTER: 'trip',
PROVIDER_DROP_OFF: 'available'
}
},
available: {
on: {
SERVICE_END: 'unavailable',
DEREGISTER: 'inactive',
RESERVE: 'reserved',
TRIP_START: 'trip',
PROVIDER_PICK_UP: 'removed'
}
},
elsewhere: {
on: {
DEREGISTER: 'inactive',
PROVIDER_PICK_UP: 'removed',
TRIP_ENTER: 'trip',
}
},
trip: {
on: {
TRIP_LEAVE: 'elsewhere',
TRIP_END: 'available',
}
},
reserved: {
on: {
CANCEL_RESERVATION: 'available',
TRIP_START: 'trip'
}
},
unavailable: {
on: {
SERVICE_START: 'available',
PROVIDER_PICKP_UP: 'removed',
DEREGISTER: 'inactive'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment