我想在ngrx存储中订阅某个状态,并且仅在该特定状态发生更改时才接收排放。
myStr1 = b'1'
myStr0 = b'0'
serialC.write(myStr1)
print(int(serialC.read().decode()))
export const getMatchesState = (state: State) => state.matches;
当我订阅这个赞
export const getSpainmatches = createSelector(getMatchesState,(allMatches) => {
return Object.keys(allMatches.byId)
.filter(key => {
return allMatches.byId[key].tournamentId == '68';
}).map(key => allMatches.byId[key]);
});
每次商店匹配更改时,我都会得到排放,不仅是西班牙匹配发生了变化。
更新:
我也尝试过:
this.testSub = this.store.pipe(select(fromRoot.getSpainmatches))
.subscribe(s => console.log('@@@@',s));
export const getSpainmatches = createSelector(getMatchesState,(allMatches,props) => {
return Object.keys(allMatches.byId)
.filter(key => {
return allMatches.byId[key].tournamentId == props.tournamentId ;
}).map(key => allMatches.byId[key]);
});
谢谢