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<FastAppOnboardingBlocState> mapEventToState(
  FastAppOnboardingBlocEvent event,
) async* {
  final payload = event.payload;
  final type = event.type;

  _logger.debug('Event received: $type');

  if (type == FastAppOnboardingBlocEventType.init) {
    yield* handleInitEvent();
  } else if (type == FastAppOnboardingBlocEventType.initialized) {
    yield* handleInitializedEvent(payload);
  } else if (isInitialized) {
    switch (type) {
      case FastAppOnboardingBlocEventType.initializationCompleted:
        yield* handleInitializationCompletedEvent();
      default:
        break;
    }
  } else {
    assert(false, 'FastAppOnboardingBloc is not initialized yet.');
  }
}