title: How to avoid an infinite loop with Observables?
body: <p>I have the following code:</p>
  
  <pre><code>ngOnInit(): void
      {  
      const source = this.categoryService.getCategories();
      console.log(source instanceof Observable);
      const example = source.map((categor) =&gt; categor.map((categories) =&gt; {
      const links = this.categoryService.countCategoryLinks(categories.id);
      const aff = example.merge(links).subscribe(linke =&gt; console.log(linke));
              return categories.id
          }));
      }
  </code></pre>
  
  <p>where <strong>getCategories()</strong> returns an observable. </p>
  
  <p>On each item of this Observable, I get <strong>categories.id</strong> field to run another method called <strong>countCategoryLinks(categories.id)</strong> that also returns an Observable().</p>
  
  <p>My problem is that : I only have 3 categories (ok), the countCategoryLinks() returns 3 items (ok) but the code above shows an <strong>infinite loop in the console</strong>.
  Both methods started "manually" for testing purpose do not show any loop. </p>
  
  <p>The problem really comes from the code above.</p>
  
  <p>Any idea ?</p>
  
  <p>Thanks in advance and Regards</p>