I am new to the whole concept of Observables and rxjs so this might be very obvious. But please help as I am desperate to learn
I have a funtion when a user clicks to show comments under a blog post
showComments(){
this.firestoreservice.getComments(this.job.id).subscribe( data =>{
this.comments = data //type [] of comment objects with (message,posterID,timeposted...)
})
this._showcomments = true;
}
This function calls a service function that returns an observable to my comments list for that job. In the subscribe to that observable is initialise a variable to hold all my comments. Before I do that however, is there a way to replace the posterID attribute of each comment with the matching username? See desired outcome below:
showComments(){
this.firestoreservice.getComments(this.job.id).subscribe( data =>{
//for each comment held in data, replace comment.posterID with getUserName(posterID)
//getUserName(posterID) will also return an observable which emmits one string
//then append comment to comments list (or add back in to data then destructively assign
//comments=data )
this.comments = data //type [] of comment objects with (message,posterID,timeposted...)
})
this._showcomments = true;
}