Skip to content

support RxJS 6 #6

@teramotodaiki

Description

@teramotodaiki

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.md

Here is a pipeable operator of ofAction.

import { ActionsObservable } from 'redux-observable';
import { Action, ActionCreator } from 'typescript-fsa';
import { filter } from 'rxjs/operators';
import { MonoTypeOperatorFunction } from 'rxjs';

export function ofAction<P>(
  actionCreator: ActionCreator<P>
): MonoTypeOperatorFunction<Action<P>> {
  return function(actions$) {
    return actions$.pipe(filter(actionCreator.match)) as ActionsObservable<
      Action<P>
    >;
  };
}

e.g.

import { ofAction } from 'typescript-fsa-redux-observable';

action$.pipe(
    ofAction(actions.someActionCreator),
    map(action => actions.otherActionCreator)
);

I think this is not the best answer, but it works.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions