Skip to contents

Asynchronous version of validate_return(), for functions that return a promise. The validator checks the resolved value, not the promise. If it fails, the promise returned by the decorated function rejects with a fnware_validation_error. Rejections from the wrapped function carry on unchanged. Needs the promises package.

Usage

async_validate_return(validator)

Arguments

validator

For validate_return(), a validator for the returned value.

Value

A decorator. The decorated function returns a promise.

Details

Arguments are available at call time, so validate_args() works for asynchronous functions as it is.

Examples

if (FALSE) { # \dontrun{
f := async_validate_return(is.character) %@%
  function() promises::promise_resolve(1)
promises::catch(f(), function(err) cat(conditionMessage(err), "\n"))
while (!later::loop_empty()) later::run_now(0.05)
} # }