You only need to use the toPayload operator if you’ve created your actions with payloads:

import { action, payload } from "ts-action";
export const Foo = action("FOO", payload<{ name: string }>());

Then your effect would look like this:

@Effect() fooAction$ = this.actions$
.ofType(Foo)
.toPayload()
.switchMap(payload => ...);

Early versions of NgRx put the action properties into a payload property, but it no longer does this. However, the structure of your actions is up to you. If you create them with payloads, toPayload is useful. Otherwise, it isn’t,

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store