Created
January 6, 2021 12:06
-
-
Save jaetask/9e3f7b0461f019e7b48c6f3a862879b1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 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