Skip to content
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

feat: default handler in createReducer #153

Merged
merged 7 commits into from
Oct 1, 2020

Conversation

Jazzmanpw
Copy link
Contributor

related to #152

@codecov
Copy link

codecov bot commented Sep 18, 2020

Codecov Report

Merging #153 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #153   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines           56        58    +2     
  Branches         9        10    +1     
=========================================
+ Hits            56        58    +2     
Impacted Files Coverage Δ
src/create-handler-map.ts 100.00% <100.00%> (ø)
src/create-reducer.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9925130...7258ef7. Read the comment docs.

@Jazzmanpw
Copy link
Contributor Author

@the-dr-lazy, it seems to fail on running yarn run docs:build, but locally it works fine (it doesn't crush at least).
I found an article in Netlify blog about such crushes, but I'm not sure if I should tweak your CI. May I ask you to check what's wrong?
This is the link to the post I found. This and some other similar posts say that errors are caused by yarn.lock/package-lock.json and some wrong stuff with node_modules committed to the repo, but I didn't change anything about the project dependencies.

src/create-handler-map.ts Outdated Show resolved Hide resolved
src/create-handler-map.ts Outdated Show resolved Hide resolved
@the-dr-lazy
Copy link
Owner

What is your opinion about renaming handleAction.default into handleAction.otherwise? I think the default word can become ambiguous with default state in Redux and users think it will call when the state is equal to the default state they have sent in reducer.
Looks like otherwise makes much more sense here.

@the-dr-lazy the-dr-lazy added the enhancement New feature or request label Sep 20, 2020
@the-dr-lazy the-dr-lazy linked an issue Sep 20, 2020 that may be closed by this pull request
@the-dr-lazy the-dr-lazy added this to the v3.2.2 milestone Sep 20, 2020
@the-dr-lazy
Copy link
Owner

the-dr-lazy commented Sep 20, 2020

@the-dr-lazy, it seems to fail on running yarn run docs:build, but locally it works fine (it doesn't crush at least).

The issue has been fixed in the next branch by 8df47a0.

@Jazzmanpw
Copy link
Contributor Author

What is your opinion about renaming handleAction.default into handleAction.otherwise? I think the default word can become ambiguous with default state in Redux and users think it will call when the state is equal to the default state they have sent in reducer.
Looks like otherwise makes much more sense here.

If we may discuss it, I think, otherwise might not be the best option.
handleAction(action), handleAction(action), handleAction.otherwise
This is what we'll receive in the end. Maybe, one of these versions will be more straight-readable:
handleAction(action), handleAction(action), handleAction.others
handleAction(action), handleAction(action), handleAction.rest

As well as, my IDE suggests handle as an argument for createReducer callback. Then handle.otherwise is clear, but a little bit off the sentence. Although I'm not an English native, so my comment on readability might not be relevant for people closer to the English language.

@the-dr-lazy
Copy link
Owner

the-dr-lazy commented Sep 26, 2020

Thank you for your comment. I'm with handleAction.others.
Also, I think it's valuable to mention in functional programming there is a technique called wildcard for pattern matching. and Deox is a representation of pattern matching for JavaScript. This PR is trying to mention this technique.

@Jazzmanpw
Copy link
Contributor Author

I've not heard about wildcard in FP, but I can see that the concept is pretty straightforward and familiar (we've all used switch ... default). Should it somehow affect the code, or is it just an idea to mention?

* introduce local InferActionFromCreator
* divide CreateHandlerMap to two smaller types
* better object-with-a-property handling with `Object.assign`
@the-dr-lazy the-dr-lazy changed the base branch from master to next October 1, 2020 19:04
@the-dr-lazy the-dr-lazy merged commit f9aec53 into the-dr-lazy:next Oct 1, 2020
@the-dr-lazy
Copy link
Owner

Thank you for your contribution @Jazzmanpw. Nice job.

@the-dr-lazy
Copy link
Owner

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Jazzmanpw
Copy link
Contributor Author

Wow, wait a moment. I appreciate that my job was useful, but I haven't finished it yet. I met some troubles with using a symbol as a key in the final handler map. The typing troubles that is. I believe I should finish it first, don't I?

@the-dr-lazy
Copy link
Owner

As this PR was not a draft I thought your work is done. Sorry for that.
Please continue your work on another PR.

@Jazzmanpw
Copy link
Contributor Author

I'm sorry about the PR status. I don't know much about it yet. I continue my work.

@the-dr-lazy the-dr-lazy linked an issue Oct 17, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released on @next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why was Deox deprecated? Add "default" section in createReducer()
3 participants