Last active
July 16, 2019 21:35
-
-
Save chrisdhanaraj/e6a52598aade491affc02010caf938d5 to your computer and use it in GitHub Desktop.
Revisions
-
chrisdhanaraj revised this gist
Jul 16, 2019 . No changes.There are no files selected for viewing
-
chrisdhanaraj revised this gist
Jul 16, 2019 . No changes.There are no files selected for viewing
-
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 13 additions 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 @@ -19,7 +19,19 @@ const suggestionMachine = Machine({ states: { idle: {}, fetching: {}, successWithResults: { on: { ADD_ITEM: { target: 'idle', action: sendParent(context => { return { type: 'ADD_ITEM', data: context } }) } } }, successNoResults: {}, failure: {} } -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 2 additions 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 @@ -84,7 +84,8 @@ const searchResultsMachine = Machine({ on: { FETCH: "fetching" } }, failure: {} } }); -
chrisdhanaraj revised this gist
Jul 16, 2019 . No changes.There are no files selected for viewing
-
chrisdhanaraj revised this gist
Jul 16, 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 @@ -92,7 +92,7 @@ const searchMachine = Machine({ id: "search", initial: "idle", context: { selectedItems: new Map() }, states: { idle: { -
chrisdhanaraj revised this gist
Jul 16, 2019 . No changes.There are no files selected for viewing
-
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 7 additions and 2 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 @@ -9,7 +9,8 @@ // - raise // - actions // - XState (all XState exports) const suggestionMachine = Machine({ id: "suggestion", initial: "idle", context: { @@ -61,7 +62,11 @@ const searchResultsMachine = Machine({ id: "searchResults", initial: "fetching", context: { searchResults: [], page: 0, pagePer: 25, sortKey: null, sortDir: 'desc' }, states: { idle: { -
chrisdhanaraj revised this gist
Jul 16, 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 @@ -92,7 +92,7 @@ const searchMachine = Machine({ states: { idle: { entry: assign({ suggestionRef: () => spawn(suggestionMachine, 'suggestions') }), on: { ADD_ITEM: "active", -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 12 additions and 4 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 @@ -43,8 +43,16 @@ const facetMachine = Machine({ FAILURE: "failure" } }, success: { on: { FETCH: 'fetching' } }, failure: { on: { FETCH: 'fetching' } } } }); @@ -93,8 +101,8 @@ const searchMachine = Machine({ }, active: { entry: assign({ facetRef: () => spawn(facetMachine, 'facet'), searchResultsRef: () => spawn(searchResultsMachine, 'searchResults') }), on: { ADD_ITEM: { -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 100 additions and 107 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 @@ -9,118 +9,111 @@ // - raise // - actions // - XState (all XState exports) const suggestionMachine = Machine({ id: "suggestion", initial: "idle", context: { suggestions: [] }, states: { idle: {}, fetching: {}, successWithResults: {}, successNoResults: {}, failure: {} } }); const facetMachine = Machine({ type: "parallel", id: "facet", initial: "fetching", context: { facets: {} }, states: { idle: { on: { FETCH: "fetching" } }, fetching: { on: { SUCCESS: "success", FAILURE: "failure" } }, success: {}, failure: {} } }); const searchResultsMachine = Machine({ type: "parallel", id: "searchResults", initial: "fetching", context: { facets: {} }, states: { idle: { on: { FETCH: "fetching" } }, fetching: { on: { SUCCESS: "success", FAILURE: "failure" } }, success: { on: { FETCH: "fetching" } } } }); const searchMachine = Machine({ id: "search", initial: "idle", context: { selectedItems: {} }, states: { idle: { entry: assign({ suggestionRef: () => spawn(suggestionMachine) }), on: { ADD_ITEM: "active", SET_ITEM: "active" } }, active: { entry: assign({ facetRef: () => spawn(facetMachine), searchResultsRef: () => spawn(searchResultsMachine) }), on: { ADD_ITEM: { target: "active", actions: [ send("FETCH", { to: context => { console.log(context); return context.facetRef } }), send("FETCH", { to: context => context.facetRef }) ] }, SET_ITEM: "active", REMOVE_ITEM: "active" } } } }); -
chrisdhanaraj revised this gist
Jul 16, 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 @@ -114,7 +114,7 @@ }), on: { ADD_ITEM: { actions: send('FETCH', { to: context => context.facetRef }) }, -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 35 additions and 29 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 @@ -67,32 +67,32 @@ } }); // const searchResultsMachine = Machine({ // type: 'parallel', // id: 'searchResults', // initial: 'fetching', // context: { // facets: {} // }, // states: { // idle: { // on: { // FETCH: 'fetching' // } // }, // fetching: { // on: { // SUCCESS: 'success', // FAILURE: 'failure' // } // }, // success: { // on: { // FETCH: 'fetching' // } // } // } // }); const searchMachine = Machine({ id: 'search', @@ -108,10 +108,16 @@ } }, active: { entry: assign({ facetRef: () => spawn(facetMachine) }), on: { ADD_ITEM: { actions: send('PING', { to: context => context.facetRef }) }, SET_ITEM: 'active', REMOVE_ITEM: 'active' } -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 1 addition 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 @@ -68,6 +68,7 @@ }); const searchResultsMachine = Machine({ type: 'parallel', id: 'searchResults', initial: 'fetching', context: { -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 1 addition 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 @@ -46,6 +46,7 @@ const facetMachine = Machine({ type: 'parallel', id: 'facet', initial: 'fetching', context: { -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 5 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 @@ -83,6 +83,11 @@ SUCCESS: 'success', FAILURE: 'failure' } }, success: { on: { FETCH: 'fetching' } } } }); -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 1 addition 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 @@ -102,6 +102,7 @@ }, active: { ...facetMachine, ...searchResultsMachine, on: { ADD_ITEM: 'active', SET_ITEM: 'active', -
chrisdhanaraj revised this gist
Jul 16, 2019 . 1 changed file with 21 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 @@ -66,6 +66,27 @@ } }); const searchResultsMachine = Machine({ id: 'searchResults', initial: 'fetching', context: { facets: {} }, states: { idle: { on: { FETCH: 'fetching' } }, fetching: { on: { SUCCESS: 'success', FAILURE: 'failure' } } } }); const searchMachine = Machine({ id: 'search', initial: 'idle', -
chrisdhanaraj revised this gist
Jul 16, 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 @@ -47,7 +47,7 @@ const facetMachine = Machine({ id: 'facet', initial: 'fetching', context: { facets: {} }, -
chrisdhanaraj created this gist
Jul 16, 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,91 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) // const fetchMachine = Machine({ // id: 'fetch', // initial: 'idle', // 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 // }) // } // } // } // } // }); const facetMachine = Machine({ id: 'facet', initial: 'idle', context: { facets: {} }, states: { idle: { on: { FETCH: 'fetching' } }, fetching: { on: { SUCCESS: 'success', FAILURE: 'failure' } } } }); const searchMachine = Machine({ id: 'search', initial: 'idle', context: { selectedItems: {} }, states: { idle: { on: { ADD_ITEM: 'active', SET_ITEM: 'active' } }, active: { ...facetMachine, on: { ADD_ITEM: 'active', SET_ITEM: 'active', REMOVE_ITEM: 'active' } } } })