// Result will be JSON from fetch. If fetch happened already in the // last 60s, return cached result. Otherwise it will fetch data constresult = awaitf();
Callback fn is passed how many milliseconds have elapsed since last update. Its minimum value will be interval.
constf = updateOutdated(asyncelapsedMs=> { // Do something with elapsedMs? }, 60*1000;
There are different policies for what to happen if fn fails. slow is the default.
fast: Invocation will happen immediately on next attempt
slow: Next invocation will wait interval as if it was successful
backoff: Attempts will get slower and slower until next success. Interval is multipled by 1.2 each time.
Calls the async
fn
to generate a value if there is no prior value orinterval
has elapsed since value was last generated.Example
Callback
fn
is passed how many milliseconds have elapsed since last update. Its minimum value will beinterval
.There are different policies for what to happen if
fn
fails.slow
is the default.fast
: Invocation will happen immediately on next attemptslow
: Next invocation will waitinterval
as if it was successfulbackoff
: Attempts will get slower and slower until next success. Interval is multipled by 1.2 each time.