danielgerlag / danielgerlag/workflow-es

waitFor - multiple events

Open
#48 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
218
Forks
52
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to do as the following:

I want my workflow to have multiple paths.
for example, I want to wait for 2 events. 1 named "manager" and the other named "client"

if the manager event happened then continue in 1 path and if the "client" event happened then continue in the second path.

But I need the workflow not to wait until both events happen.

I need it to continue and complete when the first (of 2) event happens

This is my example code:

````
export class HelloWorldWorkflow implements WorkflowBase {
public id: string = 'hello-world';
public version: number = 1;

public build(builder: WorkflowBuilder) {
builder
.startWith(HelloWorld)
.parallel()
.do(branch1 => branch1
.startWith(HelloWorld1)
.waitFor('manager', data => '0')
.output((step, data) => step.eventData && console.log(`Event manager`))

.then(HelloWorld2),
)
.do(branch2 => branch2
.startWith(HelloWorld3)
.waitFor('client', data => '0')
.output((step, data) => step.eventData && console.log(`Event client`))
.then(HelloWorld4),
)
.join()
.then(GoodbyeWorld);
}
}

But in my example, the workflow will end only after both events happen.

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.