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()
staticawaitCondition(predicate,interval,timeout):Promise<void>
Defined in: src/sdk/utils/time/Wait.ts:59
Waits for a condition to be satisfied.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
predicate | () => boolean | undefined | A function which evaluates whether the condition is satisfied. |
interval | number | 0 | The 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. |
timeout | number | 0 | The 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()
staticawaitConsumer<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
| Parameter | Type | Default value | Description |
|---|---|---|---|
consumer | Consumer<T> | undefined | The event consumer to wait for. |
predicate? | (value) => boolean | undefined | A 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? | boolean | false | Whether to immediately receive an event from the event consumer at the start of the wait. Defaults to false. |
timeout? | number | 0 | The 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()
staticawaitDelay(delay):Promise<void>
Defined in: src/sdk/utils/time/Wait.ts:13
Waits for a set amount of time.
Parameters
| Parameter | Type | Description |
|---|---|---|
delay | number | The amount of time to wait in milliseconds. |
Returns
Promise<void>
a Promise which is fulfilled after the delay.
awaitFrames()
staticawaitFrames(count,glassCockpitRefresh):Promise<void>
Defined in: src/sdk/utils/time/Wait.ts:23
Waits for a certain number of frames to elapse.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
count | number | undefined | The number of frames to wait. |
glassCockpitRefresh | boolean | false | Whether to wait for glass cockpit refresh frames instead of CoherentGT frames. Defaults to false. |
Returns
Promise<void>
awaitSubEvent()
staticawaitSubEvent<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
| Parameter | Type | Default value | Description |
|---|---|---|---|
event | ReadonlySubEvent<SenderType, DataType> | undefined | The event to wait for. |
predicate? | (data, sender) => boolean | undefined | A 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? | number | 0 | The 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()
staticawaitSubscribable<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
| Parameter | Type | Default value | Description |
|---|---|---|---|
subscribable | Subscribable<T> | undefined | The subscribable to wait for. |
predicate? | (value) => boolean | undefined | A 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? | boolean | false | Whether to immediately receive a notification from the subscribable at the start of the wait. Defaults to false. |
timeout? | number | 0 | The 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.