I have an entity like this
interface IDevice {
id: string;
name: string;
brand: string;
plan: 'contract' | 'unlocked';
}
and an entity store
interface DevicesState extends EntityState<IDevice> {
selectedBrand: string | undefined;
selectedPlan: 'contract' | 'unlocked';
}
And I want to query and filter the entities based on the brand selected.
My only attempt was this
selectedBrand$ = this.select('selectedBrand');
selectedPlan$ = this.select('selectedPlan');
devices$ = this.selectedBrand$
? this.selectAll({
filterBy: [
entity => entity.brand === this.selectedBrand$,
entity => entity.plan === this.selectedPlan$,
]
})
: this.selectMany([]);
This will not work since this.selectedBrand$
is an observable. How do I select the devices based on two outer state values?