async (version 0.0.0.9004)

async_replicate: Replicate an async function a number of times

Description

Similar to base::replicate(), with some differences:

  • it takes an async function, instead of an expression, and

  • it always returns a list.

Usage

async_replicate(n, task, ..., .limit = Inf)

Arguments

n

Number of replications.

task

Async function to call.

...

Additional arguments to task.

.limit

Number of concurrent async processes to create.

Value

Resolves to a list of the results of the n task calls.

Examples

Run this code
# NOT RUN {
## perform an HTTP request three times, and list the reponse times
do <- function() {
  async_replicate(3,
    function() http_get("https://eu.httpbin.org")$then(function(x) x$times))
}
synchronise(do())
# }

Run the code above in your browser using DataLab