Skip to content

Commit 623bcb4

Browse files
committed
user [nfc]: Add HasUserStore for other substores to use
Like HasRealmStore for data about the realm, this will help make it convenient for other substores to refer to data about users.
1 parent 5233cfb commit 623bcb4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/model/user.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import 'store.dart';
1111

1212
/// The portion of [PerAccountStore] describing the users in the realm.
1313
mixin UserStore on PerAccountStoreBase, RealmStore {
14+
@protected
15+
RealmStore get realmStore;
16+
1417
/// The user with the given ID, if that user is known.
1518
///
1619
/// There may be other users that are perfectly real but are
@@ -203,6 +206,17 @@ mixin ProxyUserStore on UserStore {
203206
UserStatus getUserStatus(int userId) => userStore.getUserStatus(userId);
204207
}
205208

209+
/// A base class for [PerAccountStore] substores that need access to [UserStore]
210+
/// as well as to its prerequisites [CorePerAccountStore] and [RealmStore].
211+
abstract class HasUserStore extends HasRealmStore with UserStore, ProxyUserStore {
212+
HasUserStore({required UserStore users})
213+
: userStore = users, super(realm: users.realmStore);
214+
215+
@protected
216+
@override
217+
final UserStore userStore;
218+
}
219+
206220
/// The implementation of [UserStore] that does the work.
207221
///
208222
/// Generally the only code that should need this class is [PerAccountStore]

0 commit comments

Comments
 (0)