async (version 0.0.0.9004)

when_all: Deferred value for a set of deferred values

Description

Create a deferred value that is resolved when all listed deferred values are resolved. Note that the error of an input deferred value triggers the error when_all as well.

Usage

when_all(..., .list = list())

Arguments

...

Deferred values.

.list

More deferred values.

Value

A deferred value, that is conditioned on all deferred values in ... and .list.

Details

async has auto-cancellation, so if one deferred value errors, the rest of them will be automatically cancelled.

See Also

when_any(), when_some()

Examples

Run this code
# NOT RUN {
## Check that the contents of two URLs are the same
afun <- async(function() {
  u1 <- http_get("https://eu.httpbin.org")
  u2 <- http_get("https://eu.httpbin.org/get")
  when_all(u1, u2)$
    then(function(x) identical(x[[1]]$content, x[[2]]$content))
})
synchronise(afun())
# }

Run the code above in your browser using DataLab