title: Best practice to use mapEventToState with incoming streams?
body: <p>Is there any elegant way to map incoming streams from a private api directly inside mapEventToState() without having to create redundant private events in the bloc?</p>
  
  <p>I came with this solution. It's ok with one single stream, but with multiple streams it starts to get a mess. Thanks in advance.</p>
  
  <pre class="lang-dart prettyprint-override"><code>// (don't mind the imports, this is the bloc file)
  
  class ExampleBloc extends Bloc&lt;ExampleEvent, ExampleState&gt; {
  
  
    final MyPrivateApi api = MyPrivateApi.instance; // singleton
  
    ExampleBloc() {
      // api has a stream of booleans
      api.myStream.listen((b) {
      // if it's true fire this event
      if (b) this.add(_MyPrivateEvent());
    }
  
    @override
    ExampleState get initialState =&gt; InitialExampleState();
  
    @override
    Stream&lt;ExampleState&gt; mapEventToState(
      ExampleEvent event,
    ) async* {
      if (event is _MyPrivateEvent) {
        yield SomeState;
      }
    }
  
  
  
  // private Event
  class _MyPrivateEvent extends ExampleEvent {
  
  }
  
  </code></pre>