Documentation
    Preparing search index...

    Type Alias RestatePromise<T>

    RestatePromise: Promise<T> & {
        map<U>(
            mapper: (value?: T, failure?: TerminalError) => U,
        ): RestatePromise<U>;
        orTimeout(millis: number | Duration): RestatePromise<T>;
    }

    A promise that can be combined using Promise combinators in RestateContext.

    Type Parameters

    • T

    Type declaration

    • map: function
      • Creates a new RestatePromise that maps the result of this promise with the provided mapper, once this promise is fulfilled.

        NOTE: You MUST use this API when you need to map the result of a RestatePromise without awaiting it, rather than using Promise.then. Promise.then is used by Restate to distinguish when awaiting an asynchronous operation, thus calling .then on several Restate promises can lead to concurrency issues.

        Type Parameters

        • U

        Parameters

        • mapper: (value?: T, failure?: TerminalError) => U

          the function to execute when this promise is fulfilled. If the promise completed successfully, value is provided as input, otherwise failure is provided as input. If this mapper returns a value, this value will be used to resolve the returned RestatePromise. If the mapper throws a TerminalError, this error will be used to reject the returned RestatePromise.

        Returns RestatePromise<U>

    • orTimeout: function