async_try_each: It runs each task in series but stops whenever any of the...

View source: R/try-each.R

async_try_eachR Documentation

It runs each task in series but stops whenever any of the functions were successful. If one of the tasks were successful, the callback will be passed the result of the successful task. If all tasks fail, the callback will be passed the error and result (if any) of the final attempt.

Description

It runs each task in series but stops whenever any of the functions were successful. If one of the tasks were successful, the callback will be passed the result of the successful task. If all tasks fail, the callback will be passed the error and result (if any) of the final attempt.

Usage

async_try_each(..., .list = list())

Arguments

...

Deferred values to run in series.

.list

More deferred values to run, .list is easier to use programmatically.

Value

Resolves to the result of the first successful deferred. Otherwise throws an error. The error objects of all failed deferreds will be in the errors member of the error object.

See Also

Other async control flow: async_backoff(), async_reflect(), async_retry(), async_retryable(), async_sequence(), async_until(), async_whilst()

Examples

do <- function() {
  async_try_each(
    async(function() stop("doh"))(),
    async(function() "cool")(),
    async(function() stop("doh2"))(),
    async(function() "cool2")()
  )
}
synchronise(do())

gaborcsardi/async documentation built on Nov. 20, 2024, 4:51 p.m.