store
store copied to clipboard
🐞[BUG]: Logger logs out of order when multiple actions are dispatched
Versions
* @angular/core: 6.0.0
* @ngxs/store: 3.2.0
* @ngxs/logger-pluggin: 3.2.0
Repro steps
Stackblitz: https://stackblitz.com/edit/angular-l4zxsn
- Create two different actions and their respective Success actions.
- Use a service to return data.
- Dispatch the two actions at the same time.
Observed behavior
When you have multiple actions that are dispatched at the same time, the logger group the actions, creating some confusion to understand what is happening.
For me, does not make sense Load Toppings to be inside of Load Pizzas. Well, I don't exactly know how grouping works, but if you use some delay, then the actions are correctly set.
ngOnInit() {
this.store.dispatch(new LoadPizzas());
this.store.dispatch(new LoadToppings());
}
@Action(LoadPizzas)
load(context: StateContext<PizzasStateModel>) {
return this.http.get('https://www.mocky.io/v2/5b8fb99d2e00002a00a89be4?mocky-delay=3000ms')
.pipe(
map(value => context.dispatch(new LoadPizzaSuccess(value)))
);
}
Desired behavior
I think that the logger should not group those Actions, since they are not exactly children of each other. It creates a little bit confusion when you look at your logs and try to understand what is happening. Actually, I don't know whether this is a normal behavior or not.
Thanks in advance! :)
This is a duplicate of issue #213.
Cancelling a previous uncompleted action results in this nesting also, I suspect the resolution for that would be the same as for this.