Skip to content

Instantly share code, notes, and snippets.

@kellyjandrews
Last active June 26, 2020 21:40
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 kellyjandrews/06496059c816b94afff35c66c007cd9c to your computer and use it in GitHub Desktop.
Save kellyjandrews/06496059c816b94afff35c66c007cd9c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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