when_some
creates a deferred value that is resolved as soon as the
specified number of deferred values resolve.
A deferred value, that is conditioned on all deferred values
in ...
and .list
.
when_any
is a special case for a single.
If the specified number of deferred values cannot be resolved, then
when_any
throws an error.
async has auto-cancellation, so if the required number of deferred values are resolved, or too many of them throw error, the rest of the are cancelled.
If when_any
throws an error, then all the underlying error objects
are returned in the errors
member of the error object thrown by
when_any
.
# \donttest{
## Use the URL that returns first
afun <- function() {
u1 <- http_get("https://eu.httpbin.org")
u2 <- http_get("https://eu.httpbin.org/get")
when_any(u1, u2)$then(function(x) x$url)
}
synchronise(afun())
#> [1] "https://eu.httpbin.org/"
# }