title: Redux Observable: How to use takeUntil inside flatMap?
body: <p>I have a flatMap with the purpose of emitting two actions:</p>
  
  <pre class="lang-js prettyprint-override"><code>export default function searchForPartner(action$, store) {
    return action$.ofType(statusActions.SEARCH_FOR_PARTNER)
      .filter(() =&gt; store.getState().user.signedIn)
      .delay(2000)
      .flatMap(() =&gt; [
        carouselActions.slideTo(config.CAROUSEL_SLIDES.CONFIRM_CHAT),
        statusActions.foundPerson(),
      ])
      .takeUntil(action$.ofType(carouselActions.TAP_CANCEL))
  };
  </code></pre>
  
  <p>However, the <code>takeUntil</code> is in the wrong spot. It is cancelling the whole epic when <code>TAP_CANCEL</code> is emitted. Instead, I only want it to cancel the emitting of the actions inside <code>flatMap</code>.  How would I do this?</p>
  
  <p>=== UPDATE ===</p>
  
  <p>I fooled around with it and this seems to work? But I don't like that there are 2 timers:</p>
  
  <pre class="lang-js prettyprint-override"><code>export default function searchForPartner(action$, store) {
    return action$.ofType(statusActions.SEARCH_FOR_PARTNER)
      .filter(() =&gt; store.getState().user.signedIn)
      .mergeMap(() =&gt;
        Observable.merge(
          Observable.timer(2000)
            .map(() =&gt; carouselActions.slideTo(config.CAROUSEL_SLIDES.CONFIRM_CHAT)),
          Observable.timer(2000)
            .map(() =&gt; statusActions.foundPerson())
        )
        .takeUntil(action$.ofType(carouselActions.TAP_CANCEL))
      )
  };
  </code></pre>