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<FastNativeAdBlocState> mapEventToState(
FastNativeAdBlocEvent event,
) async* {
final type = event.type;
final payload = event.payload;
if (payload is FastNativeAdBlocEventPayload) {
if (type == FastNativeAdBlocEventType.init) {
yield* handleInitEvent(payload);
} else if (type == FastNativeAdBlocEventType.initalized) {
yield* handleInitializedEvent(payload);
} else if (isInitialized) {
if (type == FastNativeAdBlocEventType.loadAd) {
yield* handleLoadAd(payload);
} else if (type == FastNativeAdBlocEventType.adLoaded) {
yield* handleAdLoaded(payload);
}
} else {
assert(false, 'FastNativeAdBloc is not initialized yet.');
}
} else {
assert(false, 'FastNativeAdBlocEventPayload is null.');
}
}