Last active
July 10, 2020 16:43
-
-
Save irishbryan/8b1b2f15e8b4d86ed1493b80a6100de7 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
// 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