GenericVault<T> constructor

GenericVault<T>(
  1. Store<VaultInfo, VaultEntry> storage, {
  2. VaultManager? manager,
  3. String? name,
  4. VaultLoader<T>? vaultLoader,
  5. Clock? clock,
  6. EventListenerMode? eventListenerMode,
  7. bool? statsEnabled,
  8. VaultStats? stats,
})

Builds a GenericVault out of a mandatory Store and a set of optional configurations

  • storage: The Store
  • manager: An optional VaultManager
  • name: The name of the vault
  • vaultLoader: The VaultLoader, that should be used to fetch a new value upon absence
  • clock: The source of time to be used on this, defaults to the system clock if not provided
  • statsEnabled: If statistics should be collected, defaults to false
  • stats: The statistics instance, defaults to DefaultVaultStats

Returns a GenericVault

Implementation

GenericVault(this.storage,
    {this.manager,
    String? name,
    VaultLoader<T>? vaultLoader,
    Clock? clock,
    EventListenerMode? eventListenerMode,
    bool? statsEnabled,
    VaultStats? stats})
    : name = name ?? Uuid().v1(),
      vaultLoader = vaultLoader ?? ((key) => Future<T?>.value()),
      clock = clock ?? Clock(),
      eventPublishingMode = eventListenerMode ?? EventListenerMode.disabled,
      streamController = StreamController.broadcast(
          sync: eventListenerMode == EventListenerMode.synchronous),
      statsEnabled = statsEnabled ?? false,
      stats = stats ?? DefaultVaultStats();