onChange method
Called whenever a Change occurs in any bloc
A change occurs when a new state is emitted.
onChange is called before a bloc's state has been updated.
Implementation
@override
void onChange(BlocBase<dynamic> bloc, Change<dynamic> change) {
super.onChange(bloc, change);
assert(() {
final context = CausalityZone.currentContext();
TrinityEventBus.instance.emit(CausalEvent(
parentId: context?.eventId,
type: CausalEventType.stateChange,
description: '${bloc.runtimeType}: state changed',
metadata: {
'bloc_type': bloc.runtimeType.toString(),
'current_state_type': change.currentState.runtimeType.toString(),
'next_state_type': change.nextState.runtimeType.toString(),
},
));
return true;
}());
}