Class: Wait
A utility class for generating Promises that wait for certain conditions before they are fulfilled.
Constructors
constructor
• new Wait(): Wait
Returns
Methods
awaitCondition
▸ awaitCondition(predicate
, interval?
, timeout?
): Promise
<void
>
Waits for a condition to be satisfied.
Parameters
Name | 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.
Defined in
src/sdk/utils/time/Wait.ts:59
awaitConsumer
▸ awaitConsumer<T
>(consumer
, predicate?
, initialCheck?
, timeout?
): Promise
<T
>
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
Name |
---|
T |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
consumer | Consumer <T > | undefined | The event consumer to wait for. |
predicate? | (value : T ) => 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.
Defined in
src/sdk/utils/time/Wait.ts:132
awaitDelay
▸ awaitDelay(delay
): Promise
<void
>
Waits for a set amount of time.
Parameters
Name | Type | Description |
---|---|---|
delay | number | The amount of time to wait in milliseconds. |
Returns
Promise
<void
>
a Promise which is fulfilled after the delay.
Defined in
src/sdk/utils/time/Wait.ts:13
awaitFrames
▸ awaitFrames(count
, glassCockpitRefresh?
): Promise
<void
>
Waits for a certain number of frames to elapse.
Parameters
Name | 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
>
Defined in
src/sdk/utils/time/Wait.ts:23
awaitSubEvent
▸ awaitSubEvent<SenderType
, DataType
>(event
, predicate?
, timeout?
): Promise
<DataType
>
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
Name |
---|
SenderType |
DataType |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
event | ReadonlySubEvent <SenderType , DataType > | undefined | The event to wait for. |
predicate? | (data : DataType , sender : SenderType ) => 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.
Defined in
src/sdk/utils/time/Wait.ts:164
awaitSubscribable
▸ awaitSubscribable<T
>(subscribable
, predicate?
, initialCheck?
, timeout?
): Promise
<T
>
Waits for a notification from a Subscribable, with an optional condition to end the wait based on the value of the subscribable.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
subscribable | Subscribable <T > | undefined | The subscribable to wait for. |
predicate? | (value : T ) => 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.
Defined in
src/sdk/utils/time/Wait.ts:98