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

  if (type == FastAppPermissionsBlocEventType.init) {
    yield* handleInitEvent();
  } else if (type == FastAppPermissionsBlocEventType.initialized) {
    if (payload is FastAppPermission) {
      yield* handleInitializedEvent(payload);
    }
  } else if (isInitialized) {
    switch (type) {
      case FastAppPermissionsBlocEventType.updateNotificationPermission:
        if (payload is FastAppPermission) {
          yield* handleUpdateNotificationPermissionEvent(payload);
        }

      case FastAppPermissionsBlocEventType.updateTrackingPermission:
        if (payload is FastAppPermission) {
          yield* handleUpdateTrackingPermissionEvent(payload);
        }

      default:
        break;
    }
  }
}