install static method
void
install({
- Future<
DVDatabaseAdapter> database()?, - DVOfflineSend? send,
- Stream<
bool> ? reachability, - bool canReachTheServer()?,
- Duration firstRetry = const Duration(seconds: 2),
- Duration maxRetry = const Duration(minutes: 5),
Wires the runtime to this device, once, as the application starts.
database opens the device store; send carries a replay request to
the server; reachability is DV.Platform.network as a stream of
whether the server can be reached, and canReachTheServer its current
answer. A replay runs as soon as this returns, so writes left queued by
the last session go without anything touching their model.
Implementation
static void install({
Future<DVDatabaseAdapter> Function()? database,
DVOfflineSend? send,
Stream<bool>? reachability,
bool Function()? canReachTheServer,
Duration firstRetry = const Duration(seconds: 2),
Duration maxRetry = const Duration(minutes: 5),
}) {
if (database != null) {
_openDatabase = database;
_database = null;
}
_send = send;
_canReach = canReachTheServer ?? () => true;
_firstRetry = firstRetry;
_maxRetry = maxRetry;
unawaited(_reachability?.cancel());
_reachability = reachability?.listen((bool reachable) {
if (reachable) _kick();
});
_kick();
}