- Notifications
You must be signed in to change notification settings - Fork27
Add ActionCreator#match method for single-argument type guard#42
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
aikoven commentedAug 18, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This is cool, thanks! How about constepic=(actions$:Observable<Action>)=>actions$.filter(typePredicate(myAction)) Another idea is to add some method to the action creator itself, like constepic=(actions$:Observable<Action>)=>actions$.filter(myAction.match) The latter would be handy in reducers as well as an alternative to // beforeif(isType(action,myAction)){// ...}// afterif(myAction.match(action)){// ...} What do you think? |
I love the match method idea. I hadn't considered that. I'll make the changes. |
NicholasBoll commentedAug 21, 2017
👍@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 releasedv2.5.0 |
This is invaluable when using
redux-observablesince RxJS is written in typescript and has super solid type checking when theObservable.prototype.filterfunction gets a valid one-arg type guard.I am open to changing the function name, I considered
createTypeGuardor maybe something else.