我的应用程序中有不同的选择器,但是由于某些原因,当对商店进行更改时,该特定选择器不会更新,我也不知道为什么。 selectDataStream
所在行的代码在第一次之后就再也不会运行,随后的存储更改也没有任何反应。我看到我的新值在商店中更新了。
组件:
ngAfterViewInit(): void {
if (this.fields && this.fields.length > 0) {
this.store$.select<any[]>(getConnections(this.connectorId))
.takeUntil(this.onDestroy$).subscribe(connections => {
this.selectDataStream.next(connections);
this.cdRef.detectChanges();
});
}
}
减速器代码:
const model = state.connectionresults[connectionId];
const updatedstate = {
...state,
connectionresults: {
...state.connectionresults,
[connectionId]: {
...model,
connections: [...payload]
}
}
};
return {
...updatedstate
};
选择器:
export const selectConnectionResults = createSelector(
selectFinderData,
(state: FinderState) => state.connectionresults
);
export const getConnections = (id) => createSelector(selectConnectionResults, entities => {
return entities[id];
});
我做错了什么,导致选择器无法触发?
答案 0 :(得分:0)
发现了问题。我在商店中更新了错误的属性,然后从其他值中进行选择。 :-)