IWI
IWI

Reputation: 1604

Ngrx how to digest the entire action stream at the top of the stream

I have actions laden all over my app. I have a root effect EffectsModule.forRoot([AmplitudeEffects])

which runs to the below function

@Injectable()
export class AmplitudeEffects {
  constructor(private actions$: Actions) {}

  @Effect({ dispatch: false })
  public amp = this.actions$.pipe(
    tap(() =>
      console.log(this.actions$)
      AmplitudeService.sendValues(eventCategory, eventName, eventDescription, eventProperty)
    )
  );
}

but what I am seeing in the console is the tap() i have on each effect showing the correct data, but the tap() => console.log(this.actions$) is showing something else regarding the actions that I don't understand. How can I get a clearer console view of what actioned happened in which sequence through the EffectsModule.forRoot... I would like to see the stuff coming out of index.js in my console.log in amplitude.effects.ts... Any ideas?

enter image description here

Upvotes: 0

Views: 77

Answers (1)

timdeschryver
timdeschryver

Reputation: 15505

You're logging the actions observable, but you need the action

  @Effect({ dispatch: false })
  public amp = this.actions$.pipe(
    tap((action) =>
      console.log(action)
      AmplitudeService.sendValues(eventCategory, eventName, eventDescription, eventProperty)
    )
  );

Upvotes: 2

Related Questions