Nicholas Jamieson
1 min readFeb 1, 2018

--

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,

--

--

Nicholas Jamieson
Nicholas Jamieson

Written by Nicholas Jamieson

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

Responses (1)