I have a side effect like this:
@Effect()
FetchAllOrders$ = this.actions$
.ofType(SalesOrderActions.FETCH_ALL_ORDERS)
.switchMap((action: Action) => {
return this.soApiService.getUsersSalesOrders(action.payload);
})
.map((salesOrders: ListDto<SalesOrderList>) => this.actions.fetchAllOrdersSuccess(salesOrders));
I would like to show a loading symbol at the start of the effect and hide it at the end.
I've created a separate set of Actions, Reducers and store state to handle showing the loading symbol.
export class BusyActions {
static SHOW_SPINNER = "SHOW_SPINNER";
static HIDE_SPINNER = "HIDE_SPINNER";
showSpinner(): Action {
return { type: BusyActions.SHOW_SPINNER };
}
hideSpinner(): Action {
return { type: BusyActions.HIDE_SPINNER };
}
export const BusyState: IBusyState = {
visible: false,
busy: false
};
I've done it this way because the loading state needs to be shared with other modules, states, etc.
How do i call my BusyActions from the side effect? I would need to call the SHOW_SPINNER at the start and HIDE_SPINNER at the end.
Have i done this correctly? Or is there a better way to handle this?