async (version 0.0.0.9004)

async_detect: Find the value of a match, asynchronously

Description

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

Usage

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

Run this code
# NOT RUN {
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)
))
# }

Run the code above in your browser using DataLab