Skip to content

Instantly share code, notes, and snippets.

@Baael
Last active November 22, 2019 16:00
Show Gist options
  • Save Baael/896a0a6dad09e0fdec225d5e4c76da53 to your computer and use it in GitHub Desktop.
Save Baael/896a0a6dad09e0fdec225d5e4c76da53 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id : 'RefineSearch',
initial : 'idle',
states : {
idle : {
on : {
"" : [
{ target : "isDone", cond : './hasInsurers' },
{ target : "load" },
]
},
},
load : {
invoke : {
src : [
"./prefetch",
"./setupData"
],
onDone : 'isDone',
onError : console.log,
},
},
isDone : {
initial : 'idle',
states : {
idle : {
on : {
updateFilter : {target:"updateFilter", actions: './setDirty'},
reset : "reset",
},
},
updateFilter : {
entry : './touch',
on : {
updateFilter : {target:"updateFilter", actions: './setDirty'},
reset : "reset",
},
after : {
1000 : 'fetch',
},
},
reset : {
entry : './reset',
after : { 100 : [
{ target:"fetch", cond : './isDirty' },
{ target:"idle" },
]}
},
fetch : {
after : { 0 : "idle" }
}
}
},
}
}, {
guards : {
"./hasInsurers" : () => {},
"./isDirty" : () => true,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment