我正在建立商店行动。我的商店模型如下所示:
{
entities: {[n:number]: Client},
ids: number[],
}
我从与给定条件对应的后端获取 id。然后我需要从后端获取那些尚未存储的实体。但我不知道如何将获取的 id 传递给withLatestFrom
函数?
const params = {
conditions,
fields: ['id']
};
this.apiService.getList(params)
.pipe(
map(resp => {
const ids: number[] = [];
resp.map((item: Client) => {
ids.push(+item.id);
});
return ids;
}),
withLatestFrom(this.checkEntities()), // how to pass ids ?
tap(resp => {
patchState({
entities: resp[1],
ids: resp[0],
loading: false
});
})
);
private checkEntities(ids: number[]) {
const params: ApiWyszukiwarka = {
conditions: {id: ids},
fields: 'all'
};
return this.apiService.getList(params);
}
或者也许我做错了什么?