title: How to cancel an observable from a different process
body: <p>Suppose you have a batch job running in a process. You're using observables as the implementation.</p>
  
  <p>Now you want to introduce an API to the client. Such that, the user is able to cancel/stop that running batch job. The API request would be in another process handled by your web server.</p>
  
  <p>I'm thinking of setting a flag in the database that the API can set and subsequently the batch job process can read to communicate the cancel signal. Is it possible for the batch job process to periodically check whether that signal is set?</p>
  
  <pre><code>  const ob = from([1,2,3]);
    ob.pipe(mergeMap(i =&gt; {
      // do something
      return of(i);
    }, undefined, 1);
  </code></pre>
  
  <p>Maybe perhaps the second parameter of mergeMap does that?</p>