I'm following the basic effect pattern of Ngrx using datapersistence.pessimisticUpdate() for a post to the server like so.
@Effect()
myUpdateCompleted$ = this.dataPersistence.pessimisticUpdate(MyActions.UpdateData, {
run: (action: UpdateData, state: MyDataPartialState) => {
return this.myDataService.updateData(action.payload)
.pipe(
map(result => ({
type: MyActions.ReloadData,
payload: result,
})
)
);
},
onError: (action: UpdateData, error) => {
console.error('Error', error);
return new HandleUpdateDataError(error);
}
});
I'd like to reload data after that update is done. However, before I reload the data I'd like to notify the user that the update finished and now a data reload is executing. My intended approach was to dispatch two actions after the update finishes. One action to notify the user (dispatch MyActions.NotifyMessage) and another to reload the data (dispatch MyActions.ReloadData). However, the datapersistence methods only allow for a single action to be returned and no provision for an array of actions to be dispatched. I've tried the solution posted on this question:
Dispatch multiple, ordered, actions from effect in NGRX
But I get the error:
Property 'payload' does not exist on type 'Action'
How do I go about doing this? Should I dump the use of the datapersistence functions and return multiple actions in some other way? If so, how can I do that within an Ngrx Effect? Any help would be highly appreciated.