Skip to content

Documentation / @eventkit/base / ScheduledAction

Class: ScheduledAction<T> ​

Represents an action that will be executed later. The callback that's passed in will be called at most once whenever execute() is called.

ScheduledAction implements PromiseLike, which means that when the action is used as a promise (i.e. when calling then() or being the subject of an await statement), the action will wait until execute() is called and then resolve or reject based on the callback's return value. Multiple accesses of the action's promise will return the same promise, but the action will only execute whenever execute() is called and the callback is resolved.

Extended by ​

Type Parameters ​

Type Parameter
T

Implements ​

  • PromiseLike<T>

Constructors ​

Constructor ​

ts
new ScheduledAction<T>(callback): ScheduledAction<T>

Parameters ​

ParameterTypeDescription
callback() => PromiseOrValue<T>The function that will be called when the action is executed.

Returns ​

ScheduledAction<T>

Methods ​

execute() ​

ts
execute(): Promise<void>

Executes the action. This will call the callback and resolve or reject the action's promise based on the callback's return value. If the action has already been executed, this method will return a promise representing the already executed callback.

Returns ​

Promise<void>


then() ​

ts
then<TResult1, TResult2>(onfulfilled?, onrejected?): PromiseLike<TResult1 | TResult2>

Returns a promise that will resolve or reject based on the callback's return value.

Type Parameters ​

Type ParameterDefault type
TResult1T
TResult2never

Parameters ​

ParameterType
onfulfilled?null | (value) => TResult1 | PromiseLike<TResult1>
onrejected?null | (reason) => TResult2 | PromiseLike<TResult2>

Returns ​

PromiseLike<TResult1 | TResult2>

Implementation of ​

ts
PromiseLike.then

Released under the MIT License.