when_some | R Documentation |
when_some
creates a deferred value that is resolved as soon as the
specified number of deferred values resolve.
when_some(count, ..., .list = list())
when_any(..., .list = list())
count |
Number of deferred values that need to resolve. |
... |
Deferred values. |
.list |
More deferred values. |
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
.
A deferred value, that is conditioned on all deferred values
in ...
and .list
.
when_all()
## 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())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.