【发布时间】:2020-04-29 05:55:23
【问题描述】:
我有这样的实体
interface IDevice {
id: string;
name: string;
brand: string;
plan: 'contract' | 'unlocked';
}
和实体商店
interface DevicesState extends EntityState<IDevice> {
selectedBrand: string | undefined;
selectedPlan: 'contract' | 'unlocked';
}
我想根据所选品牌查询和过滤实体。
我唯一的尝试是这个
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.selectedBrand$ 是可观察的。如何根据两个外部状态值选择设备?
【问题讨论】:
-
现在可以在将
forkJoin替换为combineLastest后工作
标签: angular typescript rxjs akita