When you call this function multiple times with the values of observables obs1 and obs2 being the same each time, the returned array may not always be the same.
getUniqueProducts(obs1: Observable<any>, obs2: Observable<any>): Observable<any> {
return combineLatest([obs1, obs2])
.pipe(
map(([prod1, prod2]) => {
return prod1.find((prod: any) => prod.NombreProducto === prod2)
}),
toArray(),
tap( a => console.log(a.length))
)
}
The goal is to retrieve objects from obs1 whose NombreProducto matches the strings provided by obs2.
In response to Liam's request, I have added more code for better clarity:
// additional code snippets here...