-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Hi,
It seems that when I set the output for a "waitFor" step, the output function is being called twice;
Execution log:
Started workflow: c41127b43cef0
Waiting for event...
event function
Publishing event...
Published event
event function
The event data is hi!
The sample code:
const workflow_es = require('workflow-es');
class LogMessage extends workflow_es.StepBody {
run(context) {
console.log(this.message);
return workflow_es.ExecutionResult.next();
}
}
class EventSample_Workflow {
constructor() {
this.id = 'event-sample';
this.version = 1;
}
build(builder) {
builder
.startWith(LogMessage)
.input((step, data) => step.message = 'Waiting for event...')
.waitFor('myEvent', (data) => '0')
.output((step, data) => {
console.log('event function');
data.externalValue = step.eventData;
})
.then(LogMessage)
.input((step, data) => step.message = 'The event data is ' + data.externalValue);
}
}
async function main() {
const config = workflow_es.configureWorkflow();
const host = config.getHost();
host.registerWorkflow(EventSample_Workflow);
await host.start();
let id = await host.startWorkflow('event-sample', 1, {});
console.log('Started workflow: ' + id);
await new Promise(resolve => setTimeout(() => resolve(), 5000));
console.log('Publishing event...');
await host.publishEvent('myEvent', '0', 'hi!', new Date());
console.log('Published event');
}
main();
Thanks
Metadata
Metadata
Assignees
Labels
No labels