ฉันมีผลง่าย ๆ :
@Effect()
simpleEffect = this.actions.pipe(
ofType<ActionA>('Action A'),
withLatestFrom(this.store.select(selectSomething)),
map(([action, something]) => console.log('CALLED TWICE'))
);
นี่คือตัวเลือก:
export const selectSomething = createSelector(
(appState) => appState.someState,
(someState) => someState.something
)
ต่อไปนี้เป็นตัวลดอย่างง่ายซึ่งอัพเดตค่า something
:
export const someReducer = (state: SomeState = someInitialState, action: ActionB) => {
switch (action.type) {
case 'Action B':
return {
...state,
something: action.payload
};
default:
return state;
}
};
ปัญหา:
เมื่อฉันส่ง ActionB เอฟเฟกต์สำหรับ ActionA จะถูกเรียก แม้ว่าจะไม่เป็นเช่นนั้นก็ตาม
ตามที่ฉันทราบ มันเกิดขึ้นเนื่องจากเอฟเฟกต์ withLatestFrom(this.store.select(selectSomething))
ซึ่งสังเกตการเปลี่ยนแปลงใดๆ ของ something
FOREVER
คำถาม:
เป็นไปได้ไหมที่จะยกเลิกการสมัครจากตัวเลือกนั้น? หรือมีฟังก์ชันอื่นแทน withLatestFrom
หรือไม่?