mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-18 02:40:33 -04:00
refactor cubits to keep them alive, wip
This commit is contained in:
parent
360ba436f8
commit
3edf2ebb46
13 changed files with 550 additions and 158 deletions
|
@ -1,17 +1,14 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:bloc_advanced_tools/bloc_advanced_tools.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../models/models.dart';
|
||||
import '../repository/account_repository.dart';
|
||||
|
||||
typedef UserLoginsState = IList<UserLogin>;
|
||||
|
||||
class UserLoginsCubit extends Cubit<UserLoginsState>
|
||||
with StateMapFollowable<UserLoginsState, TypedKey, UserLogin> {
|
||||
class UserLoginsCubit extends Cubit<UserLoginsState> {
|
||||
UserLoginsCubit(AccountRepository accountRepository)
|
||||
: _accountRepository = accountRepository,
|
||||
super(accountRepository.getUserLogins()) {
|
||||
|
@ -34,15 +31,6 @@ class UserLoginsCubit extends Cubit<UserLoginsState>
|
|||
await super.close();
|
||||
await _accountRepositorySubscription.cancel();
|
||||
}
|
||||
|
||||
/// StateMapFollowable /////////////////////////
|
||||
@override
|
||||
IMap<TypedKey, UserLogin> getStateMap(UserLoginsState state) {
|
||||
final stateValue = state;
|
||||
return IMap.fromIterable(stateValue,
|
||||
keyMapper: (e) => e.superIdentityRecordKey, valueMapper: (e) => e);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
final AccountRepository _accountRepository;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue