Skip to main content

Class: Wait

Defined in: src/sdk/utils/time/Wait.ts:7

A utility class for generating Promises that wait for certain conditions before they are fulfilled.

Constructors

Constructor

new Wait(): Wait

Returns

Wait

Methods

awaitCondition()

static awaitCondition(predicate, interval, timeout): Promise<void>

Defined in: src/sdk/utils/time/Wait.ts:59

Waits for a condition to be satisfied.

Parameters

ParameterTypeDefault valueDescription
predicate() => booleanundefinedA function which evaluates whether the condition is satisfied.
intervalnumber0The interval, in milliseconds, at which to evaluate the condition. A zero or negative value causes the condition to be evaluated every frame. Defaults to 0.
timeoutnumber0The amount of time, in milliseconds, before the returned Promise is rejected if the condition is not satisfied. A zero or negative value causes the Promise to never be rejected and the condition to be continually evaluated until it is satisfied. Defaults to 0.

Returns

Promise<void>

a Promise which is fulfilled when the condition is satisfied.


awaitConsumer()

static awaitConsumer<T>(consumer, predicate?, initialCheck?, timeout?): Promise<T>

Defined in: src/sdk/utils/time/Wait.ts:132

Waits for an event from a Consumer, with an optional condition to end the wait based on the value of the consumed event.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDefault valueDescription
consumerConsumer<T>undefinedThe event consumer to wait for.
predicate?(value) => booleanundefinedA function which evaluates whether the value of the consumed event satisfies the condition for the wait to end. If not defined, any value is considered satisfactory.
initialCheck?booleanfalseWhether to immediately receive an event from the event consumer at the start of the wait. Defaults to false.
timeout?number0The amount of time, in milliseconds, before the returned Promise is rejected if the condition is not satisfied. A zero or negative value causes the Promise to never be rejected. Defaults to 0.

Returns

Promise<T>

A Promise which is fulfilled with the value of the consumed event when an event is received with a value that satisfies the condition for the wait to end.


awaitDelay()

static awaitDelay(delay): Promise<void>

Defined in: src/sdk/utils/time/Wait.ts:13

Waits for a set amount of time.

Parameters

ParameterTypeDescription
delaynumberThe amount of time to wait in milliseconds.

Returns

Promise<void>

a Promise which is fulfilled after the delay.


awaitFrames()

static awaitFrames(count, glassCockpitRefresh): Promise<void>

Defined in: src/sdk/utils/time/Wait.ts:23

Waits for a certain number of frames to elapse.

Parameters

ParameterTypeDefault valueDescription
countnumberundefinedThe number of frames to wait.
glassCockpitRefreshbooleanfalseWhether to wait for glass cockpit refresh frames instead of CoherentGT frames. Defaults to false.

Returns

Promise<void>


awaitSubEvent()

static awaitSubEvent<SenderType, DataType>(event, predicate?, timeout?): Promise<DataType>

Defined in: src/sdk/utils/time/Wait.ts:164

Waits for an event from a ReadonlySubEvent, with an optional condition to end the wait based on the sender and data of the event.

Type Parameters

Type Parameter
SenderType
DataType

Parameters

ParameterTypeDefault valueDescription
eventReadonlySubEvent<SenderType, DataType>undefinedThe event to wait for.
predicate?(data, sender) => booleanundefinedA function which evaluates whether the sender and data of the event satisfy the condition for the wait to end. If not defined, any sender/data is considered satisfactory.
timeout?number0The amount of time, in milliseconds, before the returned Promise is rejected if the condition is not satisfied. A zero or negative value causes the Promise to never be rejected. Defaults to 0.

Returns

Promise<DataType>

A Promise which is fulfilled with the data of the event when an event is received with a sender and data that satisfy the condition for the wait to end.


awaitSubscribable()

static awaitSubscribable<T>(subscribable, predicate?, initialCheck?, timeout?): Promise<T>

Defined in: src/sdk/utils/time/Wait.ts:98

Waits for a notification from a Subscribable, with an optional condition to end the wait based on the value of the subscribable.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDefault valueDescription
subscribableSubscribable<T>undefinedThe subscribable to wait for.
predicate?(value) => booleanundefinedA function which evaluates whether the value of the subscribable satisfies the condition for the wait to end. If not defined, any value is considered satisfactory.
initialCheck?booleanfalseWhether to immediately receive a notification from the subscribable at the start of the wait. Defaults to false.
timeout?number0The amount of time, in milliseconds, before the returned Promise is rejected if the condition is not satisfied. A zero or negative value causes the Promise to never be rejected. Defaults to 0.

Returns

Promise<T>

A Promise which is fulfilled with the value of the subscribable when a notification is received with a value that satisfies the condition for the wait to end.