Skip to content

Instantly share code, notes, and snippets.

@jktravis
Created July 13, 2021 14:38
Show Gist options
  • Save jktravis/bc2611753f6ea21d117e10a2e719b73f to your computer and use it in GitHub Desktop.
Save jktravis/bc2611753f6ea21d117e10a2e719b73f 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: 'top',
initial: "clean",
states: {
clean: {
initial: 'loaded',
states: {
loaded: {
on: {
edit: {
target: '#top.dirty'
},
search: {
target: 'searching',
}
},
},
searching: {
on: {
done: {target: 'loaded'},
error: {target: 'loaded'},
}
}
}
},
dirty: {
initial: 'loaded',
states: {
loaded: {
on: {
save: {
target: '#top.clean'
},
edit: {
target: 'loaded'
},
search: {
target: 'searching',
},
}
},
searching: {
on: {
done: {target: 'loaded'},
error: {target: 'loaded'},
}
}
}
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment