All predicates are running in parallel, and the returned match is not guaranteed to be the first one.

async_detect(.x, .p, ..., .limit = Inf)

Arguments

.x

A list or atomic vector.

.p

An asynchronous predicate function.

...

Additional arguments to the predicate function.

.limit

Number of elements to process simulateneously. If it is 1, then the predicate is applied sequentially.

Value

A deferred value for the result.

See also

Other async iterators: async_every(), async_filter(), async_map()

Examples

# \donttest{
synchronise(async_detect(
  c("https://eu.httpbin.org/status/404", "https://eu.httpbin.org",
    "https://eu.httpbin.org/status/403"),
  async_sequence(http_head, function(x) x$status_code == 200)
))
#> [1] "https://eu.httpbin.org"
# }