Last active
November 26, 2019 19:17
Revisions
-
arcdev1 revised this gist
Nov 26, 2019 . No changes.There are no files selected for viewing
-
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 7 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 @@ -72,6 +72,13 @@ type: 'final' } } },{ guards: { isEmailBlank: ctx => ctx.email == null || ctx.email.trim().length < 1 }, actions: { cacheEmail: assign({email: (_,e)=>e.email}) }, }) // const appMachine = Machine({ -
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 120 additions and 93 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 @@ -21,7 +21,34 @@ ready: { type: 'parallel', states: { email: { initial: 'unvalidated', states: { unvalidated: { on: { EMAIL_CHANGE: { actions: 'cacheEmail' }, EMAIL_BLUR: [{ cond: 'isEmailBlank', target: 'validated.empty' }, { cond: 'isEmailBadFormat', target: 'validated.badFormat' }, { target: 'validated.valid' }] } }, validated: { states: { valid: {}, badFormat: {}, empty: {}, } } } }, password: {}, rememberMe: { initial: 'no', @@ -47,95 +74,95 @@ } }) // const appMachine = Machine({ // id: 'app', // initial: 'anonymous', // context: { // session: null // }, // states: { // anonymous: { // on: { // CLICK_LOGIN: 'loggingIn', // CLICK_JOIN: 'signingUp', // AUTHENTICATED: { // target: 'loggedIn', // actions: 'cacheSession' // } // } // }, // loggingIn: { // invoke: { // id: 'login-machine', // src: loginMachine, // onDone: { // target: 'loggedIn', // actions: 'cacheSession' // } // } // }, // loggingOut: { // invoke: { // id: 'lougout-machine', // src: 'logoutMachine', // onDone: { // target: 'anonymous', // actions: 'clearSession' // } // } // }, // loggedIn: { // type: 'parallel', // on: { // CLICK_LOGOUT: 'loggingOut' // }, // states: { // builderMenu: { // initial: 'closed', // states: { // open: { // on: { // TOGGLE_BUILDER_MENU: 'closed' // } // }, // closed: { // on: { // TOGGLE_BUILDER_MENU: 'open' // } // } // } // }, // profileMenu: { // initial: 'closed', // states: { // open: { // on: { // TOGGLE_PROFILE_MENU: 'closed' // } // }, // closed: { // on: { // TOGGLE_PROFILE_MENU: 'open' // } // } // } // } // } // }, // signingUp: { // invoke: { // id: 'signup-machine', // src: 'signupMacine', // onDone: { // target: 'loggedIn', // actions: 'cacheSession' // } // } // } // }, // actions: { // cacheSession: // assign({session: (_ , e) => e.session || e.data.session}), // clearSession: assign({session: null}) // } // }) -
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 9 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 @@ -15,8 +15,7 @@ initial: 'ready', context: { email: null, password: null }, states: { ready: { @@ -25,16 +24,16 @@ email: {}, password: {}, rememberMe: { initial: 'no', states: { yes: { on: { TOGGLE_REMEMBER_ME: 'no' } }, no: { on: { TOGGLE_REMEMBER_ME: 'yes' } } } @@ -43,11 +42,8 @@ }, waiting: {}, loggedIn: { type: 'final' } } }) -
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 22 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 @@ -19,15 +19,35 @@ rememberMe: false }, states: { ready: { type: 'parallel', states: { email: {}, password: {}, rememberMe: { states: { initial: 'unchecked', checked: { on: { TOGGLE_REMEMBER_ME: 'unchecked' } }, unchecked: { on: { TOGGLE_REMEMBER_ME: 'checked' } } } } } }, waiting: {}, loggedIn: { type: 'final', data: { session: (_, e) => e.session } }, } }) -
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 32 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 @@ -74,8 +74,36 @@ CLICK_LOGOUT: 'loggingOut' }, states: { builderMenu: { initial: 'closed', states: { open: { on: { TOGGLE_BUILDER_MENU: 'closed' } }, closed: { on: { TOGGLE_BUILDER_MENU: 'open' } } } }, profileMenu: { initial: 'closed', states: { open: { on: { TOGGLE_PROFILE_MENU: 'closed' } }, closed: { on: { TOGGLE_PROFILE_MENU: 'open' } } } } } }, signingUp: { @@ -91,6 +119,7 @@ }, actions: { cacheSession: assign({session: (_ , e) => e.session || e.data.session}), clearSession: assign({session: null}) } }) -
arcdev1 revised this gist
Nov 26, 2019 . 1 changed file with 20 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 @@ -58,7 +58,26 @@ } } }, loggingOut: { invoke: { id: 'lougout-machine', src: 'logoutMachine', onDone: { target: 'anonymous', actions: 'clearSession' } } }, loggedIn: { type: 'parallel', on: { CLICK_LOGOUT: 'loggingOut' }, states: { builderMenu: {}, profileMenu: {} } }, signingUp: { invoke: { id: 'signup-machine', -
arcdev1 created this gist
Nov 26, 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,77 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const loginMachine = Machine({ id: 'login', initial: 'ready', context: { email: null, password: null, rememberMe: false }, states: { ready: {}, waiting: {}, loggedIn: { type: 'final', data: { session: (_, e) => e.session } }, error: {} } }) const appMachine = Machine({ id: 'app', initial: 'anonymous', context: { session: null }, states: { anonymous: { on: { CLICK_LOGIN: 'loggingIn', CLICK_JOIN: 'signingUp', AUTHENTICATED: { target: 'loggedIn', actions: 'cacheSession' } } }, loggingIn: { invoke: { id: 'login-machine', src: loginMachine, onDone: { target: 'loggedIn', actions: 'cacheSession' } } }, loggedIn: {}, signingUp: { invoke: { id: 'signup-machine', src: 'signupMacine', onDone: { target: 'loggedIn', actions: 'cacheSession' } } } }, actions: { cacheSession: assign({session: (_ , e) => e.session || e.data.session}) } })