Last active
September 20, 2019 21:32
-
-
Save larrybotha/15c143d743a94880f8e30dbce3794a46 to your computer and use it in GitHub Desktop.
Revisions
-
Larry Botha revised this gist
Sep 20, 2019 . No changes.There are no files selected for viewing
-
Larry Botha revised this gist
Sep 20, 2019 . No changes.There are no files selected for viewing
-
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 4 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 @@ -36,10 +36,6 @@ const xeroOrgMachine = Machine({ }, }, selectOrg: { on: { ORG_SELECTED: { @@ -91,6 +87,10 @@ const xeroOrgMachine = Machine({ }, }, }, orgFound: { type: "final", }, } }, { guards: { -
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 31 additions and 31 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 @@ -28,6 +28,37 @@ const xeroOrgMachine = Machine({ }, }, gettingOrgs: { invoke: { src: "getOrgs", onDone: "selectOrg", onError: "error.getOrgs", }, }, orgFound: { type: "final", }, selectOrg: { on: { ORG_SELECTED: { target: "exchangingToken" }, CREATE_ORG: { target: "creatingOrg", } } }, creatingOrg: { invoke: { src: "createOrg", onDone: "exchangingToken", onError: "error.createOrg" } }, error: { states: { tokenExchange: { @@ -60,37 +91,6 @@ const xeroOrgMachine = Machine({ }, }, }, } }, { guards: { -
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 31 additions and 13 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,8 +18,8 @@ const xeroOrgMachine = Machine({ onDone: "orgFound", onError: [ { cond: "noAssociatedOrg", target: "gettingOrgs", }, { target: "error.tokenExchange" @@ -28,14 +28,6 @@ const xeroOrgMachine = Machine({ }, }, error: { states: { tokenExchange: { @@ -45,10 +37,17 @@ const xeroOrgMachine = Machine({ }, }, }, createOrg: { on: { RETRY: { target: "#xeroOrg.creatingOrg" }, }, }, getOrgs: { on: { RETRY: { target: "#xeroOrg.gettingOrgs" }, }, }, @@ -62,6 +61,22 @@ const xeroOrgMachine = Machine({ }, }, gettingOrgs: { invoke: { src: "getOrgs", onDone: "selectOrg", onError: "error.getOrgs", }, }, creatingOrg: { invoke: { src: "createOrg", onDone: "exchangingToken", onError: "error.createOrg" } }, orgFound: { type: "final", }, @@ -70,12 +85,15 @@ const xeroOrgMachine = Machine({ on: { ORG_SELECTED: { target: "exchangingToken" }, CREATE_ORG: { target: "creatingOrg", } } }, } }, { guards: { noAssociatedOrg: () => Math.random() > .5 } }); -
Larry Botha revised this gist
Sep 20, 2019 . No changes.There are no files selected for viewing
-
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 6 additions and 15 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 @@ -29,21 +29,10 @@ const xeroOrgMachine = Machine({ }, multipleOrgs: { invoke: { src: "getOrgs", onDone: "selectOrg", onError: "error.multipleOrgs", } }, @@ -73,12 +62,14 @@ const xeroOrgMachine = Machine({ }, }, orgFound: { type: "final", }, selectOrg: { on: { ORG_SELECTED: { target: "exchangingToken" } } }, -
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 3 additions and 3 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 @@ -22,7 +22,7 @@ const xeroOrgMachine = Machine({ target: "multipleOrgs", }, { target: "error.tokenExchange" }, ], }, @@ -49,7 +49,7 @@ const xeroOrgMachine = Machine({ error: { states: { tokenExchange: { on: { RETRY: { target: "#xeroOrg.exchangingToken", @@ -63,7 +63,7 @@ const xeroOrgMachine = Machine({ }, }, }, requestAuthUrl: { on: { RETRY: { target: "#xeroOrg.noOrg" -
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 2 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 @@ -49,7 +49,7 @@ const xeroOrgMachine = Machine({ error: { states: { tokenExchangeFailure: { on: { RETRY: { target: "#xeroOrg.exchangingToken", @@ -63,7 +63,7 @@ const xeroOrgMachine = Machine({ }, }, }, requestAuthUrlFailure: { on: { RETRY: { target: "#xeroOrg.noOrg" -
Larry Botha revised this gist
Sep 20, 2019 . 1 changed file with 11 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 @@ -75,6 +75,16 @@ const xeroOrgMachine = Machine({ orgFound: {}, selectOrg: { on: { ORG_SELECTED: { target: "#xeroOrg.exchangingToken" } } }, } }, { guards: { hasMultipleOrgs: () => true } }); -
Larry Botha created this gist
Sep 20, 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,80 @@ const xeroOrgMachine = Machine({ id: 'xeroOrg', initial: 'noOrg', states: { noOrg: { invoke: { src: "requestAuthUrl", onDone: "exchangingToken", onError: "error.requestAuthUrl", }, }, exchangingToken: { invoke: { src: "exchangeToken", onDone: "orgFound", onError: [ { cond: "hasMultipleOrgs", target: "multipleOrgs", }, { target: "error.exchangeToken" }, ], }, }, multipleOrgs: { initial: "fetching", invoke: { src: "getOrgs", onDone: "multipleOrgs.success", onError: "#xeroOrg.error.multipleOrgs", }, states: { fetching: {}, success: { on: { SELECT_ORG: "#xeroOrg.exchangingToken", }, }, } }, error: { states: { exchangeToken: { on: { RETRY: { target: "#xeroOrg.exchangingToken", }, }, }, multipleOrgs: { on: { RETRY: { target: "#xeroOrg.multipleOrgs" }, }, }, requestAuthUrl: { on: { RETRY: { target: "#xeroOrg.noOrg" } } }, }, }, orgFound: {}, selectOrg: {}, } });