Skip to content

Instantly share code, notes, and snippets.

@sandwichsudo
Last active July 30, 2021 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandwichsudo/d6084f982484639d6c28a80faaf976ae to your computer and use it in GitHub Desktop.
Save sandwichsudo/d6084f982484639d6c28a80faaf976ae to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const door = Machine({
id: 'door',
initial: 'idle',
states: {
idle: {
context: {
participants: [],
},
on: {
CONNECTED: 'inProgress',
HANG_UP: 'wrapUp'
}
},
inProgress: {
initial: 'active',
states: {
active: {
on: {
HOLD: 'onHold',
}
},
onHold: {
on: {
RESUME: 'active',
}
},
},
on: {
HANG_UP: 'wrapUp'
},
activities: {
listeningToSocket: (context, event) => {
// listen to Twilio websocket
return () => {
// clean up websocket
}
}
}
},
wrapUp: {
on: {
RECORD_OUTCOME: 'idle'
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment