title: Preventing duplicates inserted when using Observable Angular 2
body: <p>I have an issue where my array is exponentially growing more and more each time I submit a post. I think it is happening in the second observable as that user object is being updated after each post to update the timestamp for when they last updated a post.</p>
  
  <p>I am trying to check on the inside observable if that post is already in the array to prevent the duplicates from being inserted to the array. For some reason this is not working.</p>
  
  <pre><code> loadPosts(url: string) {
      switch (url) {
          case '/timeline/top':
              this.postsService.subscribeAllPosts(this.selectedArea)
                  .subscribe(posts =&gt; {
                      let container = new Array&lt;PostContainer&gt;();
                      for (let post of posts) {
                          this.getEquippedItemsForUsername(post.username).subscribe(x =&gt; {
                                  try {
                                      if (container.indexOf(new PostContainer(post, x[0].equippedItems)) === -1) {
                                          container.push(new PostContainer(post, x[0].equippedItems));
                                      }
                                       console.log( container); // grows exponentially after each submitted post
                                  } catch (ex) { }
                              }
                          );
                      }
                      this.postContainers = container; // postContainers is the array that is being looped over in the html.
                  });
              break;
     }
  
  }
  </code></pre>