Last active
April 25, 2020 03:55
-
-
Save hosmelq/38b8d30b2d5b040e4090b07899d2b4be to your computer and use it in GitHub Desktop.
Revisions
-
hosmelq revised this gist
Apr 25, 2020 . No changes.There are no files selected for viewing
-
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 43 additions and 39 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 @@ -17,7 +17,6 @@ Machine( SUBMIT: `creating`, }, states: { search: { initial: `idle`, states: { @@ -47,51 +46,56 @@ Machine( }, data: { initial: `idle`, states: { idle: { on: { SELECT_MODALITY: `loading`, }, }, loading: { onDone: `idle`, type: `parallel`, states: { grades: { initial: `loading`, states: { loading: { invoke: { id: `loadGrades`, src: `loadGrades`, onDone: { actions: `setGrades`, target: `done`, }, }, }, done: { type: `final`, }, }, }, services: { initial: `loading`, states: { loading: { invoke: { id: `loadServices`, src: `loadServices`, onDone: { actions: `setServices`, target: `done`, }, }, }, done: { type: `final`, }, }, }, }, }, -
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 68 additions and 50 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 @@ -12,74 +12,92 @@ Machine( }, states: { editing: { type: `parallel`, on: { SUBMIT: `creating`, }, states: { // searching: { search: { initial: `idle`, states: { idle: { on: { SEARCH: { cond: `searchValid`, target: `loading`, }, TYPE: { actions: [`assignQuery`, `cancelSearch`, `sendSearchEvent`], }, }, }, loading: { invoke: { id: `searchStudents`, src: `searchStudents`, onDone: { actions: `setStudents`, target: `idle`, }, }, } }, }, data: { // onDone: `editing`, type: `parallel`, states: { grades: { initial: `idle`, states: { idle: { on: { SELECT_MODALITY: `loading`, } }, loading: { invoke: { id: `loadGrades`, src: `loadGrades`, onDone: { actions: `setGrades`, target: `done`, }, }, }, done: { type: `final`, }, }, }, services: { initial: `loading`, states: { loading: { invoke: { id: `loadServices`, src: `loadServices`, onDone: { actions: `setServices`, target: `done`, }, }, }, done: { type: `final`, }, }, }, }, }, } }, creating: { @@ -116,8 +134,8 @@ Machine( // ctx.query = query }), cancelSearch: cancel(`debouncedSearch`), sendSearchEvent: send(`SEARCH`, { delay: 2500, id: `debouncedSearch`, }), }, -
hosmelq revised this gist
Apr 23, 2020 . No changes.There are no files selected for viewing
-
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 11 additions and 7 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 @@ -1,9 +1,12 @@ const {cancel} = actions Machine( { id: `createContract`, initial: `editing`, context: { grades: [], query: ``, services: [], students: [], }, @@ -17,7 +20,7 @@ Machine( target: `searching`, }, TYPE_SEARCH_STUDENT: { actions: [`assignQuery`, `cancelSearch`, `sendSearchEvent`], }, }, }, @@ -109,17 +112,18 @@ Machine( // ctx.services = event.data.allServices }), assignQuery: assign((ctx, {query}) => { // ctx.query = query }), cancelSearch: cancel(`debouncedSearch`), sendSearchEvent: send(`SEARCH_STUDENT`, { delay: 250, id: `debouncedSearch`, }), }, guards: { hasErrors: (ctx, event) => false, // !!event.data?.errors, searchValid: (ctx) => true, // ctx.query?.length > 0, }, } ) -
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 5 additions and 5 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 @@ -100,13 +100,13 @@ Machine( { actions: { setStudents: assign((ctx, event) => { // ctx.students = event.data.search.edges.map((edge) => edge.node) }), setGrades: assign((ctx, event) => { // ctx.grades = event.data.allGrades }), setServices: assign((ctx, event) => { // ctx.services = event.data.allServices }), cancelSearch: actions.cancel(`debouncedSearch`), @@ -118,8 +118,8 @@ Machine( })), }, guards: { hasErrors: (ctx, event) => false, // !!event.data?.errors, searchValid: (ctx, event) => true, // event.query?.length > 0, }, } ) -
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 11 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 @@ -4,7 +4,6 @@ Machine( initial: `editing`, context: { grades: [], services: [], students: [], }, @@ -18,7 +17,7 @@ Machine( target: `searching`, }, TYPE_SEARCH_STUDENT: { actions: [`cancelSearch`, `sendSearchEvent`], }, }, }, @@ -101,27 +100,26 @@ Machine( { actions: { setStudents: assign((ctx, event) => { ctx.students = event.data.search.edges.map((edge) => edge.node) }), setGrades: assign((ctx, event) => { ctx.grades = event.data.allGrades }), setServices: assign((ctx, event) => { ctx.services = event.data.allServices }), cancelSearch: actions.cancel(`debouncedSearch`), sendSearchEvent: send((ctx, event) => ({ delay: 250, id: `debouncedSearch`, type: `SEARCH_STUDENT`, query: event.query, })), }, guards: { hasErrors: (ctx, event) => !!event.data?.errors, searchValid: (ctx, event) => event.query?.length > 0, }, } ) -
hosmelq revised this gist
Apr 23, 2020 . No changes.There are no files selected for viewing
-
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 14 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 @@ -3,9 +3,10 @@ Machine( id: `createContract`, initial: `editing`, context: { grades: [], query: ``, services: [], students: [], }, states: { editing: { @@ -16,6 +17,9 @@ Machine( cond: `searchValid`, target: `searching`, }, TYPE_SEARCH_STUDENT: { actions: [`assignQuery`, `cancelSearch`, `sendSearchEvent`], }, }, }, @@ -105,6 +109,15 @@ Machine( setServices: assign((ctx, event) => { // ctx.services = event.data.allServices }), assignQuery: assign((ctx, {query}) => { // ctx.query = query }), cancelSearch: actions.cancel(`debouncedSearch`), sendSearchEvent: send(`SEARCH_STUDENT`, { delay: 2500, id: `debouncedSearch`, }), }, guards: { hasErrors: (ctx, event) => false, -
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 21 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 @@ -3,6 +3,7 @@ Machine( id: `createContract`, initial: `editing`, context: { students: [], grades: [], services: [], }, @@ -11,6 +12,10 @@ Machine( on: { SELECT_MODALITY: `loading`, SUBMIT: `creating`, SEARCH_STUDENT: { cond: `searchValid`, target: `searching`, }, }, }, @@ -60,6 +65,17 @@ Machine( }, }, searching: { invoke: { id: `searchStudents`, src: `searchStudents`, onDone: { actions: `setStudents`, target: `editing`, }, }, }, creating: { invoke: { id: `createContract`, @@ -80,6 +96,9 @@ Machine( }, { actions: { setStudents: assign((ctx, event) => { // ctx.students = event.data }), setGrades: assign((ctx, event) => { // ctx.grades = event.data.allGrades }), @@ -88,7 +107,8 @@ Machine( }), }, guards: { hasErrors: (ctx, event) => false, searchValid: (ctx, event) => true, }, } ) -
hosmelq revised this gist
Apr 23, 2020 . 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 @@ -81,10 +81,10 @@ Machine( { actions: { setGrades: assign((ctx, event) => { // ctx.grades = event.data.allGrades }), setServices: assign((ctx, event) => { // ctx.services = event.data.allServices }), }, guards: { -
hosmelq revised this gist
Apr 23, 2020 . 1 changed file with 20 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 @@ -2,6 +2,10 @@ Machine( { id: `createContract`, initial: `editing`, context: { grades: [], services: [], }, states: { editing: { on: { @@ -21,7 +25,10 @@ Machine( invoke: { id: `loadGrades`, src: `loadGrades`, onDone: { actions: `setGrades`, target: `done`, }, }, }, @@ -38,7 +45,10 @@ Machine( invoke: { id: `loadServices`, src: `loadServices`, onDone: { actions: `setServices`, target: `done`, }, }, }, @@ -69,6 +79,14 @@ Machine( }, }, { actions: { setGrades: assign((ctx, event) => { ctx.grades = event.data.allGrades }), setServices: assign((ctx, event) => { ctx.services = event.data.allServices }), }, guards: { hasErrors: (ctx, event) => !!event.data?.errors, }, -
hosmelq created this gist
Apr 23, 2020 .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,76 @@ Machine( { id: `createContract`, initial: `editing`, states: { editing: { on: { SELECT_MODALITY: `loading`, SUBMIT: `creating`, }, }, loading: { onDone: `editing`, type: `parallel`, states: { grades: { initial: `loading`, states: { loading: { invoke: { id: `loadGrades`, src: `loadGrades`, onDone: `done`, }, }, done: { type: `final`, }, }, }, services: { initial: `loading`, states: { loading: { invoke: { id: `loadServices`, src: `loadServices`, onDone: `done`, }, }, done: { type: `final`, }, }, }, }, }, creating: { invoke: { id: `createContract`, src: `createContract`, onDone: `success`, onError: { actions: `handleGraphQLErrors`, target: `editing`, }, }, }, success: { entry: `createContractSuccess`, type: `final`, }, }, }, { guards: { hasErrors: (ctx, event) => !!event.data?.errors, }, } )