Skip to content

Instantly share code, notes, and snippets.

@the-main-thing
Created June 12, 2020 15:10
Show Gist options
  • Save the-main-thing/c425688ae7674978f16e64b282d06970 to your computer and use it in GitHub Desktop.
Save the-main-thing/c425688ae7674978f16e64b282d06970 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const subscriptionMachine = Machine({
id: 'subscribe',
initial: 'idle',
context: {
interval: null,
},
on: {
CLOSE: {
target: 'stopped'
}
},
states: {
idle: {
on: {
LISTEN: 'listening'
}
},
listening: {
on: {
INTERVAL_CALL: 'recieving',
ERROR: {
target: 'stopped',
actions: ['onError']
}
}
},
recieving: {
on: {
RECIEVED: {
target: 'listening',
actions: ['onMessage', 'acknowledge']
},
ERROR: {
target: 'listening',
actions: ['onError']
}
}
},
stopped: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment