title: ngrx selectors with filters
body: <p>I'm using @ngrx in an Angular application and I'd like to abstract one of the recurrent patterns that I already have.</p>
  
  <p>My state is typically is composed of many states like this:</p>
  
  <pre><code>myState: {
    data: any
    isLoading: boolean
    isLoaded: boolean
  }
  </code></pre>
  
  <p>so what I end up doing in the code is subscribing to it but I only want to be notified if the state has been loaded.</p>
  
  <pre><code>this.store
    .select(state =&gt; state.myState)
    .filter(myState =&gt; myState.isLoaded)
    .map(myState =&gt; myState.data)
    .do(data =&gt; do_whatever_I_need_to_do)
    .subscribe();
  </code></pre>
  
  <p>this works for me, but I was wondering if I could simplify the first 3 operators as they are quite recurrent.</p>
  
  <p>By using selectors I could create something like this</p>
  
  <pre><code>const selectMyState = (state) =&gt; state.myState;
  
  export const getData = createSelector(selectMyState, state =&gt; state.data)
  </code></pre>
  
  <p>and then use it like this</p>
  
  <pre><code>this.store
    .select(getData)
    .do(data =&gt; do_whatever_I_need_to_do)
    .subscribe();
  </code></pre>
  
  <p>but then I'm missing the filter part, so I might get stream events from it even though my data has not yet been loaded.</p>
  
  <p>Is there any way to include that missing filter into the observable?
  I know the createSelector has a function as param, so that I can do some code in there, but I'm not sure how I would use that to filter not data, but the event itself.</p>
  
  <p>Any ideas? Thanks!</p>