Created
August 13, 2021 11:56
-
-
Save sandwichsudo/8f34ef33eafb16895bf73fc5e7f4cf22 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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