Skip to content

Commit

Permalink
store [nfc]: Add indirection doLoadPerAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbobbe committed Oct 17, 2024
1 parent 325c663 commit 18914a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions lib/model/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ abstract class GlobalStore extends ChangeNotifier {
/// This method should be called only by the implementation of [perAccount].
/// Other callers interested in per-account data should use [perAccount]
/// and/or [perAccountSync].
Future<PerAccountStore> loadPerAccount(int accountId);
Future<PerAccountStore> loadPerAccount(int accountId) {
return doLoadPerAccount(accountId);
}

/// Load per-account data for the given account, unconditionally.
///
/// This method should be called only by [loadPerAccount].
Future<PerAccountStore> doLoadPerAccount(int accountId);

// Just the Iterables, not the actual Map, to avoid clients mutating the map.
// Mutations should go through the setters/mutators below.
Expand Down Expand Up @@ -682,7 +689,7 @@ class LiveGlobalStore extends GlobalStore {
final AppDatabase _db;

@override
Future<PerAccountStore> loadPerAccount(int accountId) async {
Future<PerAccountStore> doLoadPerAccount(int accountId) async {
final updateMachine = await UpdateMachine.load(this, accountId);
return updateMachine.store;
}
Expand Down
2 changes: 1 addition & 1 deletion test/model/store_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class LoadingTestGlobalStore extends TestGlobalStore {
Map<int, List<Completer<PerAccountStore>>> completers = {};

@override
Future<PerAccountStore> loadPerAccount(int accountId) {
Future<PerAccountStore> doLoadPerAccount(int accountId) {
final completer = Completer<PerAccountStore>();
(completers[accountId] ??= []).add(completer);
return completer.future;
Expand Down
2 changes: 1 addition & 1 deletion test/model/test_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class TestGlobalStore extends GlobalStore {
}

@override
Future<PerAccountStore> loadPerAccount(int accountId) {
Future<PerAccountStore> doLoadPerAccount(int accountId) {
final initialSnapshot = _initialSnapshots[accountId]!;
final store = PerAccountStore.fromInitialSnapshot(
globalStore: this,
Expand Down

0 comments on commit 18914a4

Please sign in to comment.