This is sometimes useful, if the function is applied to entries in a vector or list.
async_reflect(task)
Async function returning a deferred value that is never
rejected. Instead its value is a list with entries error
and
result
. If the original deferred was resolved, then error
is
NULL
. If the original deferred was rejected, then result
is
NULL
.
Other async control flow:
async_backoff()
,
async_retry()
,
async_retryable()
,
async_sequence()
,
async_try_each()
,
async_until()
,
async_whilst()
badfun <- async(function() stop("oh no!"))
safefun <- async_reflect(badfun)
synchronise(when_all(safefun(), "good"))
#> [[1]]
#> [[1]]$error
#> <async error: oh no!
#> in *action* callback of `deferred$new` at ?/?:?:?>
#> [[1]]$result
#> NULL
#>
#>
#> [[2]]
#> [1] "good"
#>