async_detect: Find the value of a match, asynchronously

View source: R/detect.R

async_detectR Documentation

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


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)
))


r-lib/async documentation built on Nov. 19, 2024, 12:08 p.m.