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<FastInterstitialAdBlocState> mapEventToState(
FastInterstitialAdBlocEvent event,
) async* {
final payload = event.payload;
final type = event.type;
_logger.debug('Event received: $type');
switch (type) {
case FastInterstitialAdBlocEventType.init:
yield* _handleInitEvent(payload);
case FastInterstitialAdBlocEventType.initialized:
yield* _handleInitializedEvent(payload);
case FastInterstitialAdBlocEventType.loadAd:
if (isInitialized) yield* _handleLoadInterstitialAdEvent();
case FastInterstitialAdBlocEventType.showAd:
if (isInitialized) yield* _handleShowInterstitialAdEvent();
default:
// Handle other events or ignore
break;
}
}