Open teramotodaiki opened 6 years ago
Thanks @teramotodaiki, I've just updated to Typescript 3.0 & redux-observable 1.0.0 & RxJS 6.x ... your suggestion was very helpful in migration. I've refined the ofAction a little further if you are interested.
This also make use of the new unknown
type in TS 3, which is very useful in modelling Actions with an unknown payload, narrowing from an Action<unknown>
to Action<P>
...
export const ofAction = <P>(actionCreator: ActionCreator<P>): OperatorFunction<Action<unknown>, Action<P>> =>
(actions$): Observable<Action<P>> =>
actions$.pipe(filter(actionCreator.match))
Thank you for useful module :)
This is a proposal (not PR). In rxjs version 6, it is recommended to use
pipe
instead of prototype. https://github.com/ReactiveX/rxjs/blob/91088dae1df097be2370c73300ffa11b27fd0100/doc/pipeable-operators.mdHere is a pipeable operator of
ofAction
.e.g.
I think this is not the best answer, but it works. Thanks!