Last active
September 17, 2020 15:25
-
-
Save ahrjarrett/a38c68f9c89d5618051b0cfc617b8be1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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 characters
| Machine({ | |
| id: 'GDAuth', | |
| initial: 'idle', | |
| context: { | |
| user: null | |
| }, | |
| states: { | |
| idle: { | |
| on: { | |
| TEST_EXECUTION_ENV: 'ssr' | |
| } | |
| }, | |
| ssr: { | |
| on: { | |
| INITIALIZE: 'init' | |
| } | |
| }, | |
| init: { | |
| on: { | |
| READ_CONTEXT: 'authFromContext' | |
| } | |
| }, | |
| authFromContext: { | |
| on: { | |
| READ_CACHE: 'authFromCache' | |
| } | |
| }, | |
| authFromCache: { | |
| on: { | |
| TRY_SSO: 'ssoPending' | |
| } | |
| }, | |
| ssoPending: { | |
| invoke: { | |
| id: 'resolveSSO', | |
| src: async (context, event) => { | |
| const result = await event(context) | |
| return result | |
| }, | |
| onDone: { | |
| target: 'success', | |
| actions: assign({ loggedIn: (_, event) => event.data | |
| }), | |
| }, | |
| onError: { | |
| target: 'ssoFailure', | |
| }, | |
| } | |
| }, | |
| ssoFailure: { | |
| on: { | |
| TRY_SDK: 'sdkPending' | |
| } | |
| }, | |
| sdkPending: { | |
| invoke: { | |
| id: 'resolveSdk', | |
| src: async (context, event) => { | |
| const result = await event(context) | |
| return result | |
| }, | |
| onDone: { | |
| target: 'success', | |
| actions: assign({ loggedIn: (_, event) => event.data | |
| }), | |
| }, | |
| onError: { | |
| target: 'failure' | |
| } | |
| } | |
| }, | |
| failure: { | |
| type: 'final' | |
| }, | |
| success: { | |
| type: 'final' | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment