mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-09-18 19:44:52 -04:00
refactor checkpoint
This commit is contained in:
parent
7bd426ce98
commit
1e6b9f4a43
12 changed files with 145 additions and 136 deletions
16
packages/veilid_support/lib/src/future_cubit.dart
Normal file
16
packages/veilid_support/lib/src/future_cubit.dart
Normal file
|
@ -0,0 +1,16 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
|
||||
import '../veilid_support.dart';
|
||||
|
||||
abstract class FutureCubit<State> extends Cubit<AsyncValue<State>> {
|
||||
FutureCubit(Future<State> fut) : super(const AsyncValue.loading()) {
|
||||
unawaited(fut.then((value) {
|
||||
emit(AsyncValue.data(value));
|
||||
// ignore: avoid_types_on_closure_parameters
|
||||
}, onError: (Object e, StackTrace stackTrace) {
|
||||
emit(AsyncValue.error(e, stackTrace));
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ export 'dht_support/dht_support.dart';
|
|||
export 'src/async_tag_lock.dart';
|
||||
export 'src/async_value.dart';
|
||||
export 'src/config.dart';
|
||||
export 'src/future_cubit.dart';
|
||||
export 'src/identity.dart';
|
||||
export 'src/json_tools.dart';
|
||||
export 'src/protobuf_tools.dart';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue