title: For Loop Inside Angular Subscribe taking too long in Ionic 4
body: <p>I have created a chat application in Ionic4 with firebase as backend. And I have given the option to create groups. So my problem is when i am trying to create a new group, my app crashes due to loading all users inside the "Create New Group" page. Here is my code:</p>
  
  <p><strong>new-group.page.ts</strong></p>
  
  <pre><code>ngOnInit() {
      this.group = {
        img: "./assets/img/default-group.png"
      };
      this.searchFriend = "";
  
      this.getData.getCurrentUser().snapshotChanges().subscribe(async (accountRes: any) =&gt; {
        let account: any = { $key: accountRes.key, ...accountRes.payload.val() };
        if (!this.groupMembers) {
          this.groupMembers = [account];
        }
      });
  
      this.getData.getUsers().snapshotChanges().subscribe(async (usersRes) =&gt; {
        console.log("Inside Second Subscribe");
        let c: any = [];
        c = usersRes.map(c =&gt; ({ key: c.key, ...c.payload.val() }));
        if (c.length &gt; 0) {
          //this loops forever not just once
          for (var i = 0; i &lt; 50; i++) {
            if (c[i].uid != this.afAuth.auth.currentUser.uid) {
              let friend = { $key: c[i].uid, ...c[i] };
              console.log("Inside For: " + i);
              this.addOrUpdateFriend(friend);
              //this.friends.push(friend);
            }
          }
        } else {
          this.friends = [];
        }
      });
    }
  </code></pre>
  
  <p>So for now I have 150 users and for each user, the for loop inside my second subscribe loops forever. Any idea what am I doing wrong here?</p>