Creates a ‘promise’ from a ‘mirai’.
Details
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’.
Examples
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)
}