1import 'dart:async';
 2
 3import 'package:health_data_store/src/database_manager.dart';
 4import 'package:health_data_store/src/types/date_range.dart';
 5
 6/// A repository is a abstraction around the [DatabaseManager]
 7///
 8/// Repositories wrap the primitive values of DB fields into more complex
 9/// types and provides domain models for the application.
10///
11/// The wrapping of an abstract class and an implementation class is necessary
12/// to avoid exposing the constructor to the public api.
13abstract class Repository<T> {
14  /// Adds a new value to the repository.
15  ///
16  /// If there is an existing value of that type at the same time it gets
17  /// overridden. This is to ensure no duplicate entries are inserted and only
18  /// the most up to date value is used.
19  Future<void> add(T value);
20
21  /// Attempts to remove a value from the repository.
22  ///
23  /// This should only be called for values for values that are known to be in
24  /// the repository.
25  Future<void> remove(T value);
26
27  /// Inclusively returns all values in the specified [range].
28  Future<List<T>> get(DateRange range);
29
30  /// Stream that emits events everytime the data changes.
31  Stream subscribe();
32}