store icon indicating copy to clipboard operation
store copied to clipboard

🐞[BUG]: Logger logs out of order when multiple actions are dispatched

Open guilhermechiara opened this issue 6 years ago • 2 comments

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.

image

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! :)

guilhermechiara avatar Sep 05 '18 11:09 guilhermechiara

This is a duplicate of issue #213.

markwhitfeld avatar Sep 10 '18 21:09 markwhitfeld

Cancelling a previous uncompleted action results in this nesting also, I suspect the resolution for that would be the same as for this.

internalsystemerror avatar Dec 02 '18 17:12 internalsystemerror