Last active
September 28, 2020 14:53
-
-
Save akkys77/dae777dba62919bca493099d9aba5f1b to your computer and use it in GitHub Desktop.
Revisions
-
akkys77 revised this gist
Sep 28, 2020 . No changes.There are no files selected for viewing
-
akkys77 revised this gist
Sep 28, 2020 . 1 changed file with 17 additions and 8 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,7 +19,9 @@ modelName: "Model Name", companyName: "Company Name", projectName: "Project Name", tmpFile: undefined, modelUrn: undefined, mongoDBElementsCount: undefined }, states: { idle: { @@ -33,12 +35,18 @@ onDone: { target: 'uploadingToForge', actions: assign({ tmpFile: (context, event) => { // console.log(event.data) // return event.data return `/tmp/${context.companyName} - ${context.projectName}/${context.modelName}` } }), message:"Uploaded to Web Back End" }, onError: { target: 'failure', actions: assign({ error: (context, event) => event.data, step: 'uploadingToWebBackEnd' }) } } }, @@ -48,7 +56,7 @@ onDone: { target: 'uploadingToMongoDB', actions: assign({ modelUrn: (context,event) =>`urn::forge:${encodeURI(context.modelName)}` }) }, onError: { @@ -63,7 +71,7 @@ onDone: { target: 'success', actions: assign({ mongoDBElementsCount: (context, event) => `45312` }) }, onError: { @@ -80,6 +88,7 @@ on: { RETRY: { target: 'uploadingToWebBackEnd', // target: (context) => context.step, actions: assign({ retries: (context, event) => context.retries + 1 }) @@ -90,8 +99,8 @@ }); function uploadToForge(context) { // return "urn::forge.com:Just a test" return setTimeout(context => Promise.resolve(context),1000) } function uploadToMongoDB(context) { -
akkys77 revised this gist
Sep 28, 2020 . 1 changed file with 63 additions and 9 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 @@ -10,23 +10,67 @@ // - actions // - XState (all XState exports) const modelUploadMachine = Machine({ id: 'modelUpload', initial: 'idle', context: { retries: 0, step: "initial", modelName: "Model Name", companyName: "Company Name", projectName: "Project Name", modelUrn: undefined }, states: { idle: { on: { UPLOADING: 'uploadingToWebBackEnd' } }, uploadingToWebBackEnd: { invoke: { // src: uploadToForge, onDone: { target: 'uploadingToForge', actions: assign({ modelUrn: (context, event) => event.data }) }, onError: { target: 'failure', actions: assign({ error: (context, event) => event.data }) } } }, uploadingToForge: { invoke: { src: uploadToForge, onDone: { target: 'uploadingToMongoDB', actions: assign({ modelUrn: (context, event) => event.data }) }, onError: { target: 'failure', actions: assign({ error: (context, event) => event.data }) } } }, uploadingToMongoDB: { invoke: { src: uploadToMongoDB, onDone: { target: 'success', actions: assign({ mongoDB: (context, event) => event.data }) }, onError: { target: 'failure', actions: assign({ error: (context, event) => event.data }) } } }, success: { @@ -35,7 +79,7 @@ failure: { on: { RETRY: { target: 'uploadingToWebBackEnd', actions: assign({ retries: (context, event) => context.retries + 1 }) @@ -44,4 +88,14 @@ } } }); function uploadToForge(context) { return Promise.resolve() // return {modelUrn:"ModelURN"} } function uploadToMongoDB(context) { // return Promise.resolve() return setTimeout(context => Promise.resolve(context),1000) }
-
akkys77 created this gist
Sep 28, 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,47 @@ // Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const fetchMachine = Machine({ id: 'upload', initial: 'idle', context: { retries: 0, step: "initial" }, states: { idle: { on: { UPLOADING: 'uploaded' } }, uploaded: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'uploaded', actions: assign({ retries: (context, event) => context.retries + 1 }) } } } } });