Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
aikoven merged 6 commits intoaikoven:masterfromAlexanderOtavka:create-type-checker
Aug 24, 2017

Conversation

@AlexanderOtavka
Copy link
Contributor

This is invaluable when usingredux-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 consideredcreateTypeGuard or maybe something else.

@aikoven
Copy link
Owner

aikoven commentedAug 18, 2017
edited
Loading

This is cool, thanks!

How aboutcreateTypePredicate? Or maybe even justtypePredicate, short enough to just inline it

constepic=(actions$:Observable<Action>)=>actions$.filter(typePredicate(myAction))

Another idea is to add some method to the action creator itself, liketest ormatch:

constepic=(actions$:Observable<Action>)=>actions$.filter(myAction.match)

The latter would be handy in reducers as well as an alternative toisType:

// beforeif(isType(action,myAction)){// ...}// afterif(myAction.match(action)){// ...}

What do you think?

@AlexanderOtavka
Copy link
ContributorAuthor

I love the match method idea. I hadn't considered that. I'll make the changes.

@NicholasBoll
Copy link

👍@AlexanderOtavka Found this PR looking for a solution for your exact use-case (redux-observable epics)

@aikoven
Copy link
Owner

Looks good!

Could you please also add a regular test, apart from typings test?

@AlexanderOtavka
Copy link
ContributorAuthor

@aikoven Done!

@AlexanderOtavkaAlexanderOtavka changed the titleAdd createTypeChecker function for partial application type guardAdd ActionCreator#match method for single-argument type guardAug 23, 2017
@aikovenaikoven merged commit904a91f intoaikoven:masterAug 24, 2017
@AlexanderOtavkaAlexanderOtavka deleted the create-type-checker branchAugust 24, 2017 03:45
@aikoven
Copy link
Owner

Thanks! I'll make a release very soon.

@AlexanderOtavka
Copy link
ContributorAuthor

You are welcome! I look forward to upgrading my project.

@aikoven
Copy link
Owner

Just releasedv2.5.0

ttamminen and fangpenlin reacted with thumbs up emojiiamarcel and fangpenlin reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@AlexanderOtavka@aikoven@NicholasBoll

[8]ページ先頭

©2009-2025 Movatter.jp