mapEventToState method
Must be implemented when a class extends BidirectionalBloc.
mapEventToState
is called whenever an event is added and will convert
that event into a new BloC state. It can yield zero, one or several states
for an event.
Implementation
@override
Stream<FastAppInfoBlocState> mapEventToState(
FastAppInfoBlocEvent event,
) async* {
final payload = event.payload;
final type = event.type;
_logger.debug('Event received: $type');
if (type == FastAppInfoBlocEventType.init) {
if (payload is FastAppInfoDocument) {
yield* handleInitEvent(payload);
}
} else if (type == FastAppInfoBlocEventType.initialized) {
if (payload is FastAppInfoDocument) {
yield* handleInitializedEvent(payload);
}
} else {
assert(false, 'FastAppInfoBloc is not initialized yet.');
}
}