| as.promise.mirai_map | R Documentation |
Creates a 'promise' from a 'mirai_map'. S3 method for
promises::as.promise().
## S3 method for class 'mirai_map'
as.promise(x)
x |
(mirai_map) object to convert to promise. |
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.
A 'promise' object.
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]
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.