as.promise.mirai_map: Make mirai_map Promise

View source: R/promises.R

as.promise.mirai_mapR Documentation

Make mirai_map Promise

Description

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

Usage

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

Arguments

x

(mirai_map) object to convert to promise.

Details

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

Uses promises::promise_all() internally: resolves to a list of values if all succeed, or rejects with the first error encountered.

Requires the promises package.

Value

A 'promise' object.

Examples


library(promises)

with(daemons(1), {
  mp <- mirai_map(1:3, function(x) { Sys.sleep(1); x })
  p <- as.promise(mp)
  print(p)
  p %...>% print
  mp[.flat]
})


mirai documentation built on Feb. 13, 2026, 9:07 a.m.