async_filter keep the elements for which .p is true. (Tested via isTRUE(). async_reject is the opposite, it drops them.

async_filter(.x, .p, ...)

async_reject(.x, .p, ...)

Arguments

.x

A list or atomic vector.

.p

An asynchronous predicate function.

...

Additional arguments to the predicate function.

Value

A deferred value for the result.

See also

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

Examples

# \donttest{
## Filter out non-working URLs
afun <- async(function(urls) {
  test_url <- async_sequence(
     http_head, function(x) identical(x$status_code, 200L))
  async_filter(urls, test_url)
})
urls <- c("https://eu.httpbin.org/get",
          "https://eu.httpbin.org/status/404")
synchronise(afun(urls))
#> [1] "https://eu.httpbin.org/get"
# }