Creates a 'promise' from a 'mirai'.
# S3 method for mirai
as.promise(x)
an object of class 'mirai'.
A 'promise' object.
This function is an S3 method for the generic as.promise
for
class 'mirai'.
Requires the promises package.
Allows a 'mirai' to be used with the promise pipe %...>%
, which
schedules a function to run upon resolution of the 'mirai'.
if (interactive() && requireNamespace("promises", quietly = TRUE)) {
library(promises)
p <- as.promise(mirai("example"))
print(p)
is.promise(p)
p2 <- mirai("completed") %...>% identity()
p2$then(cat)
is.promise(p2)
}