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

Parameter Description
T

Constructors

Constructor Alerts Description
(constructor)(execute) Beta Constructs a new instance of the LazyPromise class

Properties

Property Alerts Modifiers Type Description
[Symbol.toStringTag] Beta readonly string

Methods

Method Alerts Return Type Description
catch(onrejected) Beta Promise<T | TResult>
finally(onfinally) Beta Promise<T>
then(onfulfilled, onrejected) Beta Promise<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

Parameter Type Description
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
Parameter Default Description
TResult never

Parameters

Parameter Modifiers Type Description
onrejected optional ((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

Parameter Modifiers Type Description
onfinally optional (() => 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
Parameter Default Description
TResult1 T
TResult2 never

Parameters

Parameter Modifiers Type Description
onfulfilled optional ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined
onrejected optional ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined

Returns

Return type: Promise<TResult1 | TResult2>