Apply an asynchronous function to each element of a vector

async_map(.x, .f, ..., .args = list(), .limit = Inf)

Arguments

.x

A list or atomic vector.

.f

Asynchronous function to apply.

...

Additional arguments to .f.

.args

More additional arguments to .f.

.limit

Number of elements to process simulateneously.

Value

Deferred value that is resolved after all deferred values from the application of .f are resolved.

See also

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

Examples

synchronise(async_map(
  seq(10, 100, by = 10) / 100,
  function(wait) delay(wait)$then(function() "OK")
))
#> [[1]]
#> [1] "OK"
#> 
#> [[2]]
#> [1] "OK"
#> 
#> [[3]]
#> [1] "OK"
#> 
#> [[4]]
#> [1] "OK"
#> 
#> [[5]]
#> [1] "OK"
#> 
#> [[6]]
#> [1] "OK"
#> 
#> [[7]]
#> [1] "OK"
#> 
#> [[8]]
#> [1] "OK"
#> 
#> [[9]]
#> [1] "OK"
#> 
#> [[10]]
#> [1] "OK"
#>