title: How to conditionally make http request in ngrx effect
body: <p>I have an effect that I would like to make a data call conditionally based on some value in the store.  Something like this:</p>
  
  <pre><code>  @Effect()
    loadRequestEffect$: Observable&lt;Action&gt; = this.actions$.pipe(
      ofType&lt;actions.RegisterDataSubscription&gt;,
      withLatestFrom(
        this.store.select(dataManagementFeature)
      ),
      switchMap(([action, data]) =&gt; {
        if (...condition...) {
          return this.http
            .get()
            .pipe(
              map(data =&gt; new actions.SetEndpointData()),
            );
        }
        else {
          return of(new actions.SetEndpointLoading());
        }
      })
  </code></pre>
  
  <p>I thought I could just 'of' the new action within switchMap, but apparently not.  It won't compile with this complaint:</p>
  
  <pre><code>ERROR in src/app/store/data-management-store/effects.ts(22,15): error TS2345: Argument of type '([action, data]: [RegisterDataSubscription, State]) =&gt; Observable&lt;SetEndpointData&gt; | Observable&lt;SetEndpointLoading&gt;' is not assignable to parameter of type '(value: [RegisterDataSubscription, State], index: number) =&gt; ObservableInput&lt;SetEndpointData&gt;'.
    Type 'Observable&lt;SetEndpointData&gt; | Observable&lt;SetEndpointLoading&gt;' is not assignable to type 'ObservableInput&lt;SetEndpointData&gt;'.
  </code></pre>
  
  <p>Any suggestions?</p>