text: Q:
  
  How to create a unified array with Rxjs?
  
  I'm looking to create a single object array from ngrx selectors.
  The problem that is happening is that it is creating an array of objects only for the last element of the array and not for everyone.
  MY CODE:
  this.userSelectorsService.usersFriends.subscribe(users => {
          users.forEach(user =>
              combineLatest([this.chatSelectorsService.getFriendLatestMessageById(user.id), this.chatSelectorsService.getTotalUnreadMessagesFriendById(user.id)])
                  .pipe(takeWhile(chatSelectors => chatSelectors[1] > 0))
                  .subscribe(chatSelectors => {
                      console.log(chatSelectors);
                      this.lastMessages$.next({
                          user,
                          latestMessage: {
                              ...chatSelectors[0],
                              isNewLastMessage: user.isClicked,
                          },
                      });
                  })
          );
      });
  
  RESULT:
  
  What i wish:
  [
      {
          "id":"1",
          "text":"In a world where changes are taking place quickly, the only strategy that will guarantee failure is to not take risks.",
          "time":"10:20",
          "isMain":false,
          "isRead":false,
          "isNewLastMessage":false
      },
      {
          "id":"2",
          "text":"tst",
          "time":"10:20",
          "isMain":false,
          "isRead":false,
          "isNewLastMessage":false
      },
      {
          "id":"3",
          "text":"tst 3",
          "time":"10:20",
          "isMain":false,
          "isRead":false,
          "isNewLastMessage":false
      }
  ]
  
  A:
  
  try to build pipes, and to be honest too many unknown things in your question.
  this.userSelectorsService.usersFriends.pipe(
    switchMap(users => {
      const set = [];
      for (const user of users) {
        // creating a set of data per user.
        set.push(combineLatest([
          of(user),
          this.chatSelectorsService.getFriendLatestMessageById(user.id),
          this.chatSelectorsService.getTotalUnreadMessagesFriendById(user.id),
        ]).pipe(
          takeWhile(([user, messageId, total] => total > 0),
          // mapping data to the structure we need
          map(([user, messageId, total]) => ({
            id: user.id,
            text: "tst",
            time: "10:20",
            isMain: false,
            isRead: false,
            isNewLastMessage: user.isClicked,
          })),
        ));
      }
      // or combineLatest(set), or combineAll(set), depends on your needs.
      return merge(...set);
    }),
    // toArray(), // in case of you want an array of all emits.
  // forwarding data to the this.lastMessages$.
  ).subscribe(formattedData => this.lastMessages$.next(formattedData));
  
  