Home > assistive-playwright-client > ScreenReaderClient > waitForMessageCondition
Execute the condition
function on each received message until it returns a truthy value or the specified timeout occurs. If there is a timeout, the promise returned by this function is rejected.
Signature:
waitForMessageCondition<T>(condition: (value: string, index: number, messages: string[]) => T | undefined, options?: {
includeCurrent?: boolean;
timeout?: number;
}): Promise<T>;
Parameter | Type | Description |
---|---|---|
condition | (value: string, index: number, messages: string[]) => T | undefined | function that is called for each message as long as it returns a falsy value. When it returns a truthy value, the process is stopped and that value is returned by waitForMessageCondition. |
options | { includeCurrent?: boolean; timeout?: number; } | includeCurrent : if true (the default), the condition function is first called for already received messages that are in messages. Otherwise, it is only called on new messages, not yet received at the time waitForMessageCondition is called. timeout : the time in milliseconds to wait before the promise returned by waitForMessageCondition is rejected (if the condition does not return a truthy value during that time). Defaults to 10000ms (10s). |
Returns:
Promise<T>