Created
May 14, 2020 18:02
-
-
Save christiannwamba/a537f1f1237f95ccf7aa1e542f49d310 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
// DEMO: History State (Shallow) | |
const poweredOnStates = { | |
lowHeat: { | |
on: { TOGGLE_HEAT: 'highHeat' } | |
}, | |
highHeat: { | |
on: { TOGGLE_HEAT: 'lowHeat' } | |
}, | |
// When this state node is activated | |
// It returns the previous state of | |
// poweredOnStates | |
// A state that remembers :) | |
hist: { | |
type: 'history' | |
} | |
} | |
const spaceHeaterMachine = Machine({ | |
id: 'spaceHeater', | |
initial: 'poweredOff', | |
states: { | |
poweredOff: { | |
on: { TOGGLE_POWER: 'poweredOn.hist' } | |
}, | |
poweredOn: { | |
on: { TOGGLE_POWER: 'poweredOff' }, | |
initial: 'lowHeat', | |
states: poweredOnStates | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment