Last active
November 13, 2019 20:23
-
-
Save MoonTahoe/db7465c3b8ead4c02f13f4ef848e264f to your computer and use it in GitHub Desktop.
Revisions
-
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -21,7 +21,7 @@ const lightBulbMachine = Machine({ entry: [ () => { alert('ya basic') window.location.refresh(); } ], type: 'final' -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 6 additions and 0 deletions.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 @@ -18,6 +18,12 @@ const lightBulbMachine = Machine({ } }, broken: { entry: [ () => { alert('ya basic') window.location.history.refresh(); } ], type: 'final' } }, -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -25,7 +25,7 @@ const lightBulbMachine = Machine({ CHANGE_COLOR: { actions: [ assign({ color: (ctx, e) => e.color || 'green' }) ] } -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -2,7 +2,7 @@ const lightBulbMachine = Machine({ id: 'light', initial: 'unlit', context: { color: "blue" }, states: { lit: { -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 9 additions and 0 deletions.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 @@ -20,5 +20,14 @@ const lightBulbMachine = Machine({ broken: { type: 'final' } }, on: { CHANGE_COLOR: { actions: [ assign({ color: 'green' }) ] } } }) -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 3 additions and 0 deletions.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 @@ -1,6 +1,9 @@ const lightBulbMachine = Machine({ id: 'light', initial: 'unlit', context: { color: "#FFFFFF" }, states: { lit: { on: { -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 19 additions and 44 deletions.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 @@ -1,46 +1,21 @@ const lightBulbMachine = Machine({ id: 'light', initial: 'unlit', states: { lit: { on: { TOGGLE:'unlit', BREAK:'broken' } }, unlit: { on: { TOGGLE:'lit', BREAK:'broken' } }, broken: { type: 'final' } } }) -
MoonTahoe revised this gist
Nov 13, 2019 . 1 changed file with 1 addition and 1 deletion.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 @@ -12,7 +12,7 @@ const fetchMachine = Machine({ id: 'fetch', initial: 'idle', context: { retries: 0 }, -
MoonTahoe created this gist
Nov 13, 2019 .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,46 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const fetchMachine = Machine({ id: 'fetch', initial: 'success', context: { retries: 0 }, states: { idle: { on: { FETCH: 'loading' } }, loading: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'loading', actions: assign({ retries: (context, event) => context.retries + 1 }) } } } } });