2

Say I have 3 asynchronous functions A,B, and C. I want to run them concurrently inside a concurrent block, but for one of the functions I want to check a condition. I'm looking for the following behaviour:

concurrent {
    await A(...);
    await B(...);
    if ($some_condition) {
        await C(...);
    }
}
kebab-case
  • 1,732
  • 1
  • 13
  • 24

1 Answers1

4

Use an async block:

concurrent {
    await A(...);
    await B(...);
    await async {
        if ($some_condition) {
            await C(...);
        }
    };
}
concat
  • 3,107
  • 16
  • 30