Skip to main content

sdk.watcher.waitforfirstcondition

Home > @matterway/sdk > Watcher > waitForFirstCondition

Watcher.waitForFirstCondition() function

High level helper which runs enter/leave when selector is being matched.

Signature:

export declare function waitForFirstCondition<T extends Conditions>(conditions: T): Promise<keyof T>;

Parameters

ParameterTypeDescription
conditionsTObject with Promises/Functions returning promises.

Returns:

Promise<keyof T>

Resolves with first resolved condition's key.

Example

const result = waitForFirstCondition({
a: () => new Promise(resolve => setTimeout(() => resolve(), 1000),
b: new Promise(resolve => setTimeout(() => resolve(), 500)
});