async (version 0.0.0.9004)

async_try_each: 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_reflect, async_retryable, async_retry, async_sequence, async_until, async_whilst

Examples

Run this code
# NOT RUN {
do <- function() {
  async_try_each(
    async(function() stop("doh"))(),
    async(function() "cool")(),
    async(function() stop("doh2"))(),
    async(function() "cool2")()
  )
}
synchronise(do())
# }

Run the code above in your browser using DataLab