Skip to content

Instantly share code, notes, and snippets.

@irishbryan
Last active July 10, 2020 16:43
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 irishbryan/8b1b2f15e8b4d86ed1493b80a6100de7 to your computer and use it in GitHub Desktop.
Save irishbryan/8b1b2f15e8b4d86ed1493b80a6100de7 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 assignInitialContext = (ctx, event) => {
// Use event data to initialize context
}
const assignPolicy = () => {}
const assignTrails = () => {}
const assignSearchPhrase = () => {}
const fetchMachine = Machine({
id: "search",
initial: "idle",
context: {
policies: [],
trails: [],
selectedTrails: [],
selectedPolicyIndex: 0,
searchPhrase: null,
},
states: {
idle: {
on: {
INITIALIZE: {
target: "started",
actions: assignInitialContext,
},
},
},
started: {
on: {
TOGGLE_ENVIRONMENT: {
actions: [assignInitialContext],
},
CHANGE_POLICY: {
actions: assignPolicy,
},
CHANGE_TRAILS: {
actions: assignTrails,
},
CHANGE_SEARCH_PHRASE: {
actions: assignSearchPhrase,
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment