Skip to content

Instantly share code, notes, and snippets.

@sandwichsudo
Created August 13, 2021 11:56
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/8f34ef33eafb16895bf73fc5e7f4cf22 to your computer and use it in GitHub Desktop.
Save sandwichsudo/8f34ef33eafb16895bf73fc5e7f4cf22 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine(
{
id: 'call',
context: {
participants: [],
color: '#fff',
},
initial: 'idle',
states: {
idle: {
on: {
CONNECTED: 'inProgress',
},
},
inProgress: {
initial: 'active',
states: {
active: {
on: {
HOLD: 'onHold',
},
},
onHold: {
on: {
RESUME: 'active',
},
},
},
on: {
HANG_UP: 'wrapUp',
ADD_PARTICIPANT: { actions: ['addParticipant'] },
CHANGE_COLOR: {
actions: ['changeColor'],
},
},
},
wrapUp: {
on: {
RECORD_OUTCOME: 'idle',
},
},
},
},
{
actions: {
// @ts-ignore
addParticipant: assign((context, event) => ({
participants: ['a'],
})),
// @ts-ignore
changeColor: assign((context, event) => ({
color: '#eee',
})),
},
activities: {
// TODO: fill this in
// @ts-ignore
listeningToSocket: (context, event) => {
// listen to Twilio websocket
return () => {
// clean up websocket
};
},
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment