Skip to content

Instantly share code, notes, and snippets.

@jaetask
Created January 6, 2021 12:06
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 jaetask/9e3f7b0461f019e7b48c6f3a862879b1 to your computer and use it in GitHub Desktop.
Save jaetask/9e3f7b0461f019e7b48c6f3a862879b1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const pipelineItemMachine = Machine({
id: 'pipelineItem',
initial: 'compact',
context: {
quotes: []
},
states: {
compact: {
on: {
EXPAND: 'fetching'
}
},
fetching: {
on: {
RESOLVE: 'expanded',
REJECT: 'failure'
}
},
expanded: {
on: {
COMPACT: 'compact',
VIEW_QUOTE: {
target: 'expanded',
actions: 'notifyParentViewQuote'
},
REQUOTE: {
target: 'expanded',
actions: 'notifyParentRequote'
}
}
},
failure: {
on: {
RETRY: {
target: 'fetching'
}
}
}
}
},{
actions: {
notifyParentViewQuote: (c,e) => {
sendParent({type: 'VIEW_QUOTE', quote: {quoteId: 1234}})
},
notifyParentRequote: (c,e) => {
sendParent({type: 'REQUOTE', quote: {quoteId: 4321}})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment