Skip to main content

LazyPromise Class

A lazy evaluated promise. The execute function is delayed until the promise is used, e.g. await, then, catch ... The execute function is only called once. All calls are then proxied to the promise returned by the execute method.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/core-utils/legacy.

For more information about our API support guarantees, see here.

Signature

export declare class LazyPromise<T> implements Promise<T>

Implements: Promise<T>

Type Parameters

ParameterDescription
T

Constructors

ConstructorAlertsDescription
(constructor)(execute)BetaConstructs a new instance of the LazyPromise class

Properties

PropertyAlertsModifiersTypeDescription
[Symbol.toStringTag]Betareadonlystring

Methods

MethodAlertsReturn TypeDescription
catch(onrejected)BetaPromise<T | TResult>
finally(onfinally)BetaPromise<T>
then(onfulfilled, onrejected)BetaPromise<TResult1 | TResult2>

Constructor Details

(constructor)

Constructs a new instance of the LazyPromise class

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

constructor(execute: () => Promise<T>);

Parameters

ParameterTypeDescription
execute() => Promise<T>

Property Details

[Symbol.toStringTag]

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get [Symbol.toStringTag](): string;

Type: string

Method Details

catch

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
Type Parameters
ParameterDefaultDescription
TResultnever

Parameters

ParameterModifiersTypeDescription
onrejectedoptional((reason: any) => TResult | PromiseLike<TResult>) | null | undefined

Returns

Return type: Promise<T | TResult>

finally

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

finally(onfinally?: (() => void) | null | undefined): Promise<T>;

Parameters

ParameterModifiersTypeDescription
onfinallyoptional(() => void) | null | undefined

Returns

Return type: Promise<T>

then

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
Type Parameters
ParameterDefaultDescription
TResult1T
TResult2never

Parameters

ParameterModifiersTypeDescription
onfulfilledoptional((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined
onrejectedoptional((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined

Returns

Return type: Promise<TResult1 | TResult2>