mergeThreads() {
const userId = this.auth.getUser().uid;
const buyerThreads$ = this.afs.collection('threads', ref => ref.where('buyerId', '==', userId)).valueChanges();
const sellerThreads$ = this.afs.collection('threads', ref => ref.where('sellerId', '==', userId)).valueChanges();
this.subscription = forkJoin(buyerThreads$, sellerThreads$)
.pipe(
map(([bT, sT]) => [...bT, ...sT])
)
.subscribe(res => {
console.log(res); // output not displaying
// logic to check for unread threads should be implemented here
});
}
In order to ascertain real-time updates regarding unread messages in my Firestore database's 'threads' collection, I have chosen to use AngularFire2 and its querying capabilities. Due to the limitations of AngularFire2 where querying with multiple conditions might yield unexpected results, I had to think of a different approach. My goal is to combine two Observable arrays into a single array to provide timely notifications to users concerning their message status.
After trying out a code snippet (borrowed from an answer on Stack Overflow), I realized that nothing was being outputted in the subscribe method. This led me to believe that perhaps my observables continue streaming without completing, hampering the subscription process. Is there a way to effectively merge two ongoing observable streams into one dynamic array, or do I need to consider an alternative strategy?