finity
finity copied to clipboard
Can I pass data to leave througth out all states?
const worker = Finity
.configure()
.initialState('ready')
.on('task_submitted').transitionTo('running')
.state('running')
// here I have the context.eventPayload
// but if I want to inside the worker gerate a data to use in another state?
.do((state, context) => processTaskAsync(context.eventPayload))
.onSuccess().transitionTo('succeeded')
.onFailure().transitionTo('failed')
.onTimeout(1000)
.transitionTo('timed_out')
.global()
.onStateEnter(state => console.log(`Entering state '${state}'`))
.start();