with_promise_domain | R Documentation |
Promise domains are used to temporarily set up custom environments that
intercept and influence the registration of callbacks. Create new promise
domain objects using new_promise_domain
, and temporarily activate a promise
domain object (for the duration of evaluating a given expression) using
with_promise_domain
.
with_promise_domain(domain, expr, replace = FALSE)
new_promise_domain(
wrapOnFulfilled = identity,
wrapOnRejected = identity,
wrapSync = force,
onError = force,
...,
wrapOnFinally = NULL
)
domain |
A promise domain object to install while |
expr |
Any R expression, to be evaluated under the influence of
|
replace |
If |
wrapOnFulfilled |
A function that takes a single argument: a function
that was passed as an |
wrapOnRejected |
A function that takes a single argument: a function
that was passed as an |
wrapSync |
A function that takes a single argument: a (lazily evaluated)
expression that the function should |
onError |
A function that takes a single argument: an error. |
... |
Arbitrary named values that will become elements of the promise
domain object, and can be accessed as items in an environment (i.e. using
|
wrapOnFinally |
A function that takes a single argument: a function
that was passed as an |
While with_promise_domain
is on the call stack, any calls to then()
(or
higher level functions or operators, like catch()
or the various pipes)
will belong to the promise domain. In addition, when a then
callback that
belongs to a promise domain is invoked, then any new calls to then
will
also belong to that promise domain. In other words, a promise domain
"infects" not only the immediate calls to then
, but also to "nested" calls
to then
.
For more background, read the original design doc.
For examples, see the source code of the Shiny package, which uses promise domains extensively to manage graphics devices and reactivity.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.