Asynchronous version of once(), for functions that return a
promise. The first call's resolved value is kept and
every later call returns a promise of it, ignoring its arguments. Calls made
while the first is still running share its promise. A rejection stores
nothing, so the next call tries again. Needs the promises package.
Examples
if (FALSE) { # \dontrun{
setup := async_once %@% function() {
cat("setting up\n")
promises::promise_resolve(42)
}
promises::then(setup(), print)
promises::then(setup(), print) # no second "setting up"
while (!later::loop_empty()) later::run_now(0.05)
} # }
