Learn R Programming

mirai (version 2.6.1)

as.promise.mirai: Make mirai Promise

Description

Creates a 'promise' from a 'mirai'. S3 method for promises::as.promise().

Usage

# S3 method for mirai
as.promise(x)

Value

A 'promise' object.

Arguments

x

(mirai) object to convert to promise.

Details

Allows a 'mirai' to be used with the promise pipe %...>%, scheduling a function to run upon resolution.

Requires the promises package.

Examples

Run this code
if (FALSE) { # 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)
}

Run the code above in your browser using DataLab