|
| 1 | +// Logs events and states during transition, needs some improvement to reduce spam |
| 2 | +// @override |
| 3 | +// String toString() => 'Event { prop: prop }'; |
| 4 | +import 'package:bloc/bloc.dart'; |
| 5 | + |
| 6 | +class SimpleBlocObserver extends BlocObserver { |
| 7 | + @override |
| 8 | + void onCreate(BlocBase bloc) { |
| 9 | + super.onCreate(bloc); |
| 10 | + print('onCreate -- ${bloc.runtimeType}'); |
| 11 | + } |
| 12 | + |
| 13 | + // @override |
| 14 | + // void onEvent(Bloc bloc, Object? event) { |
| 15 | + // super.onEvent(bloc, event); |
| 16 | + |
| 17 | + // if ({ProcessFileExtractorOutput, ProcessFileExtractorProgress} |
| 18 | + // .contains(event)) print('onEvent -- ${bloc.runtimeType}, $event'); |
| 19 | + // } |
| 20 | + |
| 21 | + // @override |
| 22 | + // void onTransition(Bloc bloc, Transition transition) { |
| 23 | + // // CurrentSettingsState and ProcessState have a lot of spam |
| 24 | + // if ({transition.nextState, transition.nextState} |
| 25 | + // .contains(CurrentSettingsState) || |
| 26 | + // {transition.nextState, transition.nextState}.contains(ProcessState)) { |
| 27 | + // print(transition); |
| 28 | + // } |
| 29 | + // super.onTransition(bloc, transition); |
| 30 | + // } |
| 31 | + |
| 32 | + @override |
| 33 | + void onError(BlocBase bloc, Object error, StackTrace stackTrace) { |
| 34 | + print('${bloc.runtimeType} $error $stackTrace'); |
| 35 | + super.onError(bloc, error, stackTrace); |
| 36 | + } |
| 37 | + |
| 38 | + @override |
| 39 | + void onClose(BlocBase bloc) { |
| 40 | + super.onClose(bloc); |
| 41 | + print('onClose -- ${bloc.runtimeType}'); |
| 42 | + } |
| 43 | +} |
0 commit comments