Skip to content

Instantly share code, notes, and snippets.

@wichopy
Last active August 20, 2020 20:49
Show Gist options
  • Save wichopy/578c6e2133e9657839f9bd0c9d0461b2 to your computer and use it in GitHub Desktop.
Save wichopy/578c6e2133e9657839f9bd0c9d0461b2 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: 'hub',
type: 'parallel',
states: {
session: {
initial: 'idle',
states: {
idle: {
on: {
START_RECORDING: 'waiting_for_devices'
}
},
waiting_for_devices: {
on: {
ERROR_CONNECTING: 'idle',
DEVICES_CONNECTING: 'connecting'
}
},
connecting: {
on : {
DONE_CONNECTING: 'recording'
}
},
recording: {
on: {
STOP_RECORDING: 'complete'
}
},
complete: {}
}
},
device: {
initial: 'idle',
states: {
power_off: {
on: {
TURN_ON: 'idle'
}
},
idle: {
on: {
NO_POWER: 'power_off',
START_RECORDING: 'connecting'
}
},
connecting: {
on: {
NO_POWER: 'power_off',
ESTABLISHED_CONNECTION: 'connected'
}
},
connected: {
on: {
NO_POWER: 'power_off',
STOP_RECORDING: 'idle',
DROPPED_CONNECTION: 'connecting'
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment