Skip to content

Instantly share code, notes, and snippets.

@samzhao
Last active Aug 21, 2020
Embed
What would you like to do?
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
Machine({
id: 'translation',
initial: 'jobComplete',
context: {
transactionId: undefined,
},
states: {
jobComplete: {
on: {
RECEIVE_JOB: {
target: 'jobReceived',
actions: assign({
transactionId: (context, event) => event.transactionId
})
},
}
},
jobReceived: {
on: {
START_PREPROCESSING: 'preppingContent'
}
},
preppingContent: {
on: {
SEND_TO_TMS: 'sendingContentToTMS'
}
},
sendingContentToTMS: {
on: {
MARK_JOB_CREATION_SUCCESS: 'jobCreatedOnTMS',
}
},
jobCreatedOnTMS: {
on: {
RECEIVE_TRANSLATION_COMPLETE_NOTIFICATION: 'processingTranslations'
}
},
processingTranslations: {
on: {
SYNC_TO_CMS: 'syncedToCMS'
}
},
syncedToCMS: {
on: {
MARK_CMS_SYNC_SUCCESS: 'jobComplete'
}
}
}
})
// const fetchMachine = Machine({
// id: 'fetch',
// initial: 'idle',
// context: {
// retries: 0
// },
// states: {
// idle: {
// on: {
// FETCH: 'loading'
// }
// },
// loading: {
// on: {
// RESOLVE: 'success',
// REJECT: 'failure'
// }
// },
// success: {
// type: 'final'
// },
// failure: {
// on: {
// RETRY: {
// target: 'loading',
// actions: assign({
// retries: (context, event) => context.retries + 1
// })
// }
// }
// }
// }
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment