Skip to main content

core.readablepromise

Home > @medplum/core > ReadablePromise

ReadablePromise class

The ReadablePromise class wraps a request promise suitable for React Suspense. See: https://blog.logrocket.com/react-suspense-data-fetching/\#wrappromise-js See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js

Signature:

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

Implements: Promise<T>

Constructors

Constructor

Modifiers

Description

(constructor)(requestPromise)

Constructs a new instance of the ReadablePromise class

Properties

Property

Modifiers

Type

Description

[Symbol.toStringTag]

readonly

string

Methods

Method

Modifiers

Description

catch(onrejected)

Attaches a callback for only the rejection of the Promise.

finally(onfinally)

Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

isOk()

Returns true if the promise resolved successfully.

isPending()

Returns true if the promise is pending.

read()

Attempts to read the value of the promise. If the promise is pending, this method will throw a promise. If the promise rejected, this method will throw the rejection reason. If the promise resolved, this method will return the resolved value.

then(onfulfilled, onrejected)

Attaches callbacks for the resolution and/or rejection of the Promise.