Lets say i have an observable that emits employees.
$employees
I wish to manipulate a sub property of each employee based on an Observable. For the example lets say display name.
Currently im performing the task like this.
const getDisplayName = (emp) => {}; //returns an observable
const mapFn = async (emp) => {
emp.displayName = await getDisplayName(emp).toPromise();
return emp;
}
$employees
.pipe(mergeMap(mapFn));
I think my confusion is that, to my understanding, we have two streams. The root $employees
and the getDisplayName
. My understanding is with the various merge operators the root value would be replaced by the value of the secondary stream. Not merged with.
Is there a better way to do this where i don't need to convert to a promise but can also just map a property of the employee?
Thanks.