refactor checkpoint

This commit is contained in:
Christien Rioux 2024-01-29 22:38:19 -05:00
parent 7bd426ce98
commit 1e6b9f4a43
12 changed files with 145 additions and 136 deletions

View 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));
}));
}
}

View file

@ -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';