Last active
February 3, 2021 13:02
Revisions
-
Jonathan Berger revised this gist
Feb 3, 2021 . 1 changed file with 2 additions and 17 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 @@ -27,13 +27,14 @@ }, forgotPassword: { on: { SUCCESS: 'success', FORGOT_BACK: 'logIn' } }, subscribe: { on: { SUCCESS: 'success', } }, oauth: { @@ -42,25 +43,9 @@ end: { type: 'final' }, success: { type: 'final' }, } });
-
Jonathan Berger created this gist
Feb 3, 2021 .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,66 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const authMachine = Machine({ id: 'auth', initial: 'logIn', context: { retries: 0 }, states: { logIn: { on: { SUCCESS: 'end', FORGOTTEN: 'forgotPassword', SUBSCRIBE: 'subscribe', OAUTH_LOGIN: 'oauth' } }, forgotPassword: { on: { FORGOT_SUCCESS: 'success', FORGOT_BACK: 'logIn' } }, subscribe: { on: { SUCCESS: 'success', } }, oauth: { SUCCESS: 'success' }, end: { type: 'final' }, loading: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'loading', actions: assign({ retries: (context, event) => context.retries + 1 }) } } } } });