-
Notifications
You must be signed in to change notification settings - Fork 296
Improved implementation of handleAction - Take 2 #109
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
Conversation
if (action.type !== typeValue) return state; | ||
const typeValue = isSymbol(type) | ||
? type | ||
: type.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works with string action types and action creators. I think calling out isSymbol
explicitly clarifies the special case (where we cannot call .toString()
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
ping @timche for the new dependencies and that general approach This is a small PR (from the long-outstanding #97) so, I'm planning to get merge sometime over the weekend. If there's no time to review, we can review retrospectively and I can address those comments after merge. |
return isFunction(reducer) | ||
? reducer(state, action) | ||
: state; | ||
return (action.error === true ? throwReducer : nextReducer)(state, action); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=== true
could be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on #97 (comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, sorry, error
could be any other value than true
. === true
adds more safety to respect FSA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! I thought the same thing when reviewing #97; thanks to @Lucretiel for doing the research and pointing it out.
After clarified all the things, this PR is very neat 👌🏻. You get my check mark after you have resolved the linting issues 😁 @Lucretiel are you also fine with that? |
Thanks, and big thanks to @Lucretiel (this is really his PR). There's a build break with b5546b5
I'll see what I can do to fix it; let me know if you have any ideas on it. |
9a317f3 fixed the build. The interesting lesson was that the environments the tests were run in had a case-insensitive filesystem, including mine:
but for some reason |
@timche what do you think of releasing this in v0.10.2? |
I would make this part of v0.11.0 with a bunch of other non-breaking PRs. Should try to follow semver. |
Squashed merged in 5e78f25. Would you consider this addition a bug fix or new functionality?
|
This is based off of the ideas in #97, which generated a lot of good discussion. Roughly:
reducers
Full credit goes to @Lucretiel; just submitting it here for a cleaner pull request.
@Lucretiel, please review as well.