Skip to content

Instantly share code, notes, and snippets.

@wyze
Created October 16, 2020 01:17
Show Gist options
  • Save wyze/bf926e9eac19fca76f3d682610b99788 to your computer and use it in GitHub Desktop.
Save wyze/bf926e9eac19fca76f3d682610b99788 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 fetchMachine = Machine({
id: 'intercom',
initial: 'idle',
context: {
intelligenceViews: 0
},
states: {
idle: {
on: {
INCREMENT: 'update',
INITIALIZE: 'seed.loading'
}
},
seed: {
states: {
loading: {},
success: {
on: {
DONE: '#intercom.idle'
}
},
failure: {}
}
},
update: {
actions: (ctx) => window.Intercom('update', ctx),
entry: assign(ctx => ({ intelligenceViews: ctx.intelligenceViews + 1 })),
on: {
'*': 'idle'
}
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment