-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ActionCreator#match method for single-argument type guard #42
Conversation
This is cool, thanks! How about const epic = (actions$: Observable<Action>) =>
actions$.filter(typePredicate(myAction)) Another idea is to add some method to the action creator itself, like const epic = (actions$: Observable<Action>) =>
actions$.filter(myAction.match) The latter would be handy in reducers as well as an alternative to // before
if (isType(action, myAction)) {
// ...
}
// after
if (myAction.match(action)) {
// ...
} What do you think? |
I love the match method idea. I hadn't considered that. I'll make the changes. |
👍 @AlexanderOtavka Found this PR looking for a solution for your exact use-case (redux-observable epics) |
Looks good! Could you please also add a regular test, apart from typings test? |
@aikoven Done! |
Thanks! I'll make a release very soon. |
You are welcome! I look forward to upgrading my project. |
Just released v2.5.0 |
This is invaluable when using
redux-observable
since RxJS is written in typescript and has super solid type checking when theObservable.prototype.filter
function gets a valid one-arg type guard.I am open to changing the function name, I considered
createTypeGuard
or maybe something else.