as.promise.mirai: Make mirai Promise

View source: R/promises.R

as.promise.miraiR Documentation

Make mirai Promise

Description

Creates a 'promise' from a 'mirai'.

Usage

## S3 method for class 'mirai'
as.promise(x)

Arguments

x

an object of class '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'.

Value

A 'promise' object.

Examples


library(promises)

p <- as.promise(mirai("example"))
print(p)
is.promise(p)

p2 <- mirai("completed") %...>% identity()
p2$then(cat)
is.promise(p2)


mirai documentation built on April 4, 2025, 12:27 a.m.