title: How to stop subscription by using multiple conditions with takeUntil
body: <h1>I wanna stop a observable subscription based on two conditions:</h1>
  <ul>
  <li>Time (using <code>import { timer } from 'rxjs/internal/observable/timer';</code>)</li>
  </ul>
  <p><strong>OR</strong></p>
  <ul>
  <li>Execution status (using the returned object from request that you'll see below)</li>
  </ul>
  <h1>What is happenning:</h1>
  <p>It's only stoping execution based on Time (using <code>import { timer } from 'rxjs/internal/observable/timer';</code>)</p>
  <h1>This is my current code:</h1>
  <p>The names of attributes, variables and their values ​​have been changed for example purposes:</p>
  <pre><code>import { finalize } from 'rxjs/internal/operators/finalize';
  import { interval } from 'rxjs/internal/observable/interval';
  import { timer } from 'rxjs/internal/observable/timer';
  import { takeUntil, first } from 'rxjs/operators';
  import { merge, EMPTY, of } from 'rxjs';
  
  .
  . // Attributes and Class declaration here
  .
  
  
  async startProcess(): Promise&lt;void&gt; {
  
      this.isProcessLoading = true;
  
      const { someId } = await this.exampleService.execute().toPromise();
  
      const interval$ = interval(1000);
      const timeLimiter$ = timer(10000);
  
      const request$ = this.exampleService.doRequest();
      
      const isEventFinished$ = EMPTY;
  
      // My goal here is for the result of this function to return an observable that notifies 
      // if the first parameter emits an event OR if the second parameter emits another. That is, I want to notify if any condition is valid
      const stopConditions$ = merge(isEventFinished$, timeLimiter$);
  
      const handleSuccess = (object: MyType) =&gt; {
  
        if (object.status === 'FINALIZED') {
  
          this.object = object;
          isEventFinished$.subscribe();
        }
      };
  
      const handleError = () =&gt;  this.showErrorComponent = true;
  
      interval$
      .pipe(takeUntil(stopConditions$))
      .pipe(finalize(() =&gt; this.isSimulationLoading = false))
      .subscribe(() =&gt; request$.subscribe(handleSuccess, handleError));
  }
  
  </code></pre>
  <p>The code &quot;works&quot; because the <code>timeLimiter$</code> fires <code>takeUntil</code> after 10s. However, I want the possibility to stop before the time limit...</p>
  <p>I want takeUntil to be able to run from here too:</p>
  <p><code>isEventFinished$.subscribe()</code></p>
  <p>if the above snippet performed correctly, it should be stop the interval$, but it does not. That is my problem</p>
  <h1>What i already tried:</h1>
  <ol>
  <li><p>I dont know if two pipes made any difference than use only one like this: <code>.pipe(takeUntil(stopConditions$), finalize(() =&gt; this.isSimulationLoading = false))</code>. However, i already tried it and did not work</p>
  </li>
  <li><p>Already tried to replace this <code>isEventFinished$</code> for: <code>const isEventFinished$ = of(1)</code>
  and his subscription by: <code>timeLimiter$.pipe(first()).subscribe()</code>.
  But this does not works either. In reality, this prevents the request from being executed (I don't know why)</p>
  </li>
  </ol>