Created
May 14, 2020 18:02
-
-
Save christiannwamba/a537f1f1237f95ccf7aa1e542f49d310 to your computer and use it in GitHub Desktop.
Revisions
-
christiannwamba created this gist
May 14, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ // 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 } } })