config method

void config({
  1. StorageInterface? storage,
  2. QueryConfig? config,
  3. List<QueryObserver>? observers,
})

Set the global default config which all queries will use.

Use cacheDuration to specify how long a query that has zero listeners stays in memory. Defaults to 5 minutes.

Use refetchDuration to specify how long before the query is re-fetched in the background. Defaults to 4 seconds

Pass a StorageInterface to automatically store queries for fast initial fetches.

shouldRethrow tells cached query whether it should rethrow any error caught in the query. This is useful if you use try catches in your app for error handling/logout. By default a query will catch all errors and exceptions and update the state.

Implementation

void config({
  StorageInterface? storage,
  QueryConfig? config,
  List<QueryObserver>? observers,
}) {
  assert(_configSet == false, "Config defaults must only be set once.");
  if (_configSet) return;

  if (config != null) {
    _config = config;
  }
  _storage = storage;
  _configSet = true;
  if (observers != null) {
    this.observers = observers;
  }

  assert(() {
    this.observers.add(DevtoolsObserver());
    return true;
  }());
}