as.promise.mirai | R Documentation |
Creates a 'promise' from a 'mirai'.
## S3 method for class 'mirai'
as.promise(x)
x |
an object of class 'mirai'. |
This function is an S3 method for the generic as.promise
for
class 'mirai'.
Requires the packages promises and later.
Allows a 'mirai' to be used with the promise pipe %...>%
, which
schedules a function to run upon resolution of the 'mirai'.
A 'promise' object.
if (interactive() &&
requireNamespace("promises", quietly = TRUE) &&
requireNamespace("later", quietly = TRUE)) {
library(promises)
p <- as.promise(mirai("example"))
print(p)
is.promise(p)
p2 <- mirai("completed") %...>% identity()
p2$then(cat)
is.promise(p2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.