I have an effect which calls Actions on 2 different states, its current state an another.
@Effect()
sendPointOfInterestChatMessage$ = this.actions$.pipe(
ofType(chatActions.ChatActionTypes.SendPointOfInterestChatMessage),
switchMap((action: chatActions.SendPointOfInterestChatMessage) => this.chatService.sendMessage(action.pointOfInterest.chatMessage.chatRoomId,
action.pointOfInterest.chatMessage.content,
false,
false,
false).pipe(
switchMap((data: any) => {
...content excluded
return [
new chatActions.AddChatMessage(chatMessage),
new mapActions.CreatePointOfInterest(copyPointOfInterest)
];
}),
catchError((error: HttpErrorResponse) => {
const errorMessage = this.handleError('Error Sending Chat Message', error);
return of(new chatActions.SendChatMessageFailure('SendChatMessageError: ' + errorMessage));
})
))
);
Both the chatActions.AddChatMessage and mapActions.CreatePointOfInterest execute successfully. However, the mapActions.CreatePointOfInterest also fires actions as follows
@Effect()
createPointOfInterest$ = this.actions$.pipe(
ofType(mapActions.MapActionTypes.CreatePointOfInterest),
switchMap((action: mapActions.CreatePointOfInterest) =>
this.mapService.createPointOfInterest(action.pointOfInterest).pipe(
switchMap((data: any) => {
...excluded content
return [new mapActions.CreatePointOfInterestSuccess(pointOfInterest), new mapActions.CreatePointOfInterestSuccess2("testing")];
}),
catchError((error: HttpErrorResponse) => {
const errorMessage = this.handleError('Error Creating Point of Interest', error, false);
return of(new mapActions.CreatePointOfInterestFailure('CreatePointOfInterestError: ' + errorMessage));
})
))
);
At this point, the mapActions.CreatePointOfInterestSuccess Action is fired as I see the call in the State inspector, however, the Reducer is not ever triggered
export function reducer(state = initialState, action: MapActions): MapState {
switch (action.type) {
case MapActionTypes.ResetError:
return {
...state,
error: null
};
case MapActionTypes.CreatePointOfInterestSuccess:
...content excluded
}
return {
...state,
pointsOfInterest: copyCreatePointOfInterestSuccessPointsOfInterest,
correlatedPointsOfInterest: copyCreatePointOfInterestSuccessCorrelatedPointsOfInterest,
error: null
};
I am never seeing the CreatePointOfSuccess reducer code actually fired. Even with CreatePointOfInterest2 that only passes a string, never gets fired. Why is this reducer never being fired?