UpdatesBuilder
Caches a single instance of type A
for a period of time before
refreshing it automatically.
The time between refreshes is dynamic and based on the value of each A
itself. This is similar to RefreshableEffect
except that only exposes a
fixed refresh frequency.
As well as the time between refreshes, the retry policy is also dynamic
and based on the value for A
. This allows you to configure the policy
based on when A
is going to expire.
You can use the cacheDuration
and retryPolicy
together to eagerly
fetch a new value for A
using the calculated cache duration minus some
duration to allow for retries and then set the retry policy to retry
throughout that duration.
An old value is only made unavailable after a new value has been
acquired. This means that the time each value is exposed for is
cacheDuration
plus the time to evaluate fa
.
- Value parameters:
- cacheDuration
how long to cache a newly generated value of
A
for, if an effect is needed to generate this duration it should have occurred infa
. Defaults to defaultCacheDuration if not specified.- defaultValue
an optional default value to use when initialising the resource, if the call to
fa
fails. This will prevent the constructor from failing during startup- exhaustedRetriesCallback
what to do if retrying to refresh the value fails. The refresh fiber will have failed at this point and the value will grow stale. It is up to user handle this failure, as they see fit, in their application
- newValueCallback
a callback invoked whenever a new value is generated, the scala.concurrent.duration.FiniteDuration is the period that will be waited before the next new value
- refresh
generate a new value of
A
- refreshFailureCallback
what to when an attempt to refresh the value fails,
fa
will be retried according toretryPolicy
- retryPolicy
a function to derive a configuration object for attempting to retry the effect of
fa
on failure from the current value ofA
. Defaults to defaultRetryPolicy when not specified
- Source:
- Refreshable.scala
Value members
Concrete methods
- Definition Classes
- Source:
- Refreshable.scala
- Definition Classes
- Source:
- Refreshable.scala