I have angular App with State management which is work in where i load data from database in observable like
let first give you interface
interface service {
id: number,
name:string,
category_id: number,
}
interface category{
id:number,
name:string,
}
As you can see there is relation between service and category which link by id which is number.
Let give you what is observable look like
services : Observable<Service[]>
categories : Observable<Category[]>
How can i merge Category name into Services into something differnt like this:
interface ServiceWithCategory{
id: number,
name:string,
category_id: number,
category:string,
}
I try to to some async pipe in angular but it don't update if category updated
const serviceswithcategory = services.pipe(
map(i => i.map((service) => {
return {
...service,
Category: `${this.async.transform(categories.pipe(map((i) => {
return i.find((a: Category) => a.id == service.category_id) }))?.name}
}`
}
})));
Now serviceswithcategory don't do anything when category get udpated. It is not reactive to category.