setSettings<T extends DBModelI> static method
Store the settings provided for a specific type of DBModelI.
If settings was provided for the same DBModelI more that once,
this will not replace the settings of the already created ModelCache
instances. The correct settings value has to set before creating
a instance of ModelCache for the given type T
.
But before instantiating the ModelCache for the type T
, this
function can be called multiple times. ModelCache will use the last
values that this function was called with.
Eg: Let's say you need to set settings for a model called User which extends DBModelI.
// Wrong way of using this function.
ModelCache.setSettings(...);
// Correct way of using this function.
ModelCache.setSettings<User>(...);
Parameter Description
addon
- An instance of RepositoryAddon for this T
timeout
- Timeout period in minutes which ModelCache will re-fetch
data from Firestore server (Default 60).
Implementation
static void setSettings<T extends DBModelI>({
required RepositoryAddon<T> addon,
int timeout = 60,
}) {
final name = T.toString();
_addons[name] = addon;
_timeouts[name] = timeout;
}