Last active
June 26, 2020 21:40
-
-
Save kellyjandrews/06496059c816b94afff35c66c007cd9c 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 promise = (ctx, e) => new Promise((resolve, reject) => { | |
console.log('got called') | |
resolve('done'); | |
}); | |
const opentokMachine = Machine({ | |
id: 'opentok', | |
initial: 'disconnected', | |
context: { | |
sessionId: null | |
}, | |
states: { | |
disconnected: { | |
id: 'disconnected', | |
initial: 'init', | |
states: { | |
init: { | |
invoke: { | |
id: 'getToken', | |
src: 'invokeGetToken', | |
onDone: { | |
target: "ready", | |
actions: 'logToken' | |
} | |
}, | |
entry: [ | |
'initSession', | |
'initPublisher' | |
] | |
}, | |
ready: { | |
on: { | |
'JOIN': '#connected' | |
} | |
}, | |
teardown: {} | |
} | |
}, | |
connected: { | |
id: 'connected', | |
on: { | |
'DISCONNECT': '#disconnected.teardown' | |
} | |
} | |
} | |
}, { | |
actions:{ | |
logToken: (ctx, e) => console.log('get token'), | |
initSession: (ctx, e) => console.log('initSession'), | |
initPublisher: (ctx, e) => console.log('initPublisher') | |
}, | |
services: { | |
invokeGetToken: async (ctx, e) => await promise() | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment