Skip to content

waitFor - multiple events #48

@AviFix

Description

@AviFix

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<any> {
  public id: string = 'hello-world';
  public version: number = 1;

  public build(builder: WorkflowBuilder<any>) {
    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

 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions