Description Usage Arguments Details Value Examples
This is a helper function that returns a promise after a delay. It can be used with any pipe and any object (see examples).
1 |
x |
An object. |
delay |
Number of seconds before resolving the promise. |
The value of the returned promise depends on the class of x
. If x
can
be coerced to a promise (using
promises::as.promise()), the value of the returned
promise is identical to the value of promises::as.promise(x)
once
fulfilled; otherwise the value of the returned promise is x
after the
delay.
A promise. See details for the value of the fulfilled promise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
library(promises)
value <- runif(1)
pr <- promise_resolve(value)
# works with `magrittr` pipe
pr %>%
wait(1) %>%
then(~ cat(., "\n"))
# works with `promises` pipe
pr %...>%
wait(1) %...>%
{ cat(., "\n") }
# also works with any object
value %>%
wait(1) %>%
then(~cat(., "\n"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.