% Generated by tinyroxygen: do not edit by hand
% Please edit documentation in promise.R
\name{then}
\alias{then}
\alias{catch}
\alias{finally}
\title{Access the results of a promise}
\usage{
then(promise, onFulfilled = NULL, onRejected = NULL)
catch(promise, onRejected)
finally(promise, onFinally)
}

\arguments{
\item{promise}{A promise object.}

\item{onFulfilled}{A function to be invoked if `promise` resolves
  successfully. Called with the resolved value, and optionally a second
  `.visible` argument indicating whether the value is
  [visible][base::invisible()].}

\item{onRejected}{A function taking a single `reason` argument, to be
  invoked if `promise` fails.}

\item{onFinally}{A function with no arguments, called when `promise`
  either succeeds or fails.}
}

\value{
A new promise.
}

\description{
Use `then()` to access the eventual result of a promise (or, if
the operation fails, the reason for that failure). The call to `then()` is
non-blocking: it returns immediately, and the return value is itself a
new promise.

`catch()` is equivalent to `then()`, but without the `onFulfilled`
argument; it is typically used at the end of a promise chain to perform
error handling.

`finally()` is similar to `then()`, but takes a single no-argument
function that is executed upon completion of the promise, regardless of
whether the result is success or failure. The return value of the
`onFinally` callback is ignored; an error thrown from it is propagated
forward into the returned promise.
}

