Skip to content

Adding some convenient initialisers #329

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

Closed
wants to merge 2 commits into from
Closed

Adding some convenient initialisers #329

wants to merge 2 commits into from

Conversation

rkreutz
Copy link

@rkreutz rkreutz commented Dec 3, 2020

Hey there, I believe this is a rather straightforward PR.

I've added a few convenience initialisers so I could combine different Reducers for different context (actions), them being:

  • init(forAction:handler) & init(forActions:handler) which will execute the Reducer's handler if it receives the provided action(s). It handles actions with or without (Void) associated values.
  • init(bindingAction:to:handler) & init(bindingAction:to:handler) which will automatically set an actions associated value to a key path in the state, optionally providing a handler to further customise state and/or trigger different side effects.

I thought this would be worth sharing :)

@stephencelis
Copy link
Member

Hey @rkreutz! This one slipped by, sorry about that! 😄 Holiday season must've caught us off guard.

These are definitely fun! We have some other reducers that we'd like to bring into the core library, but think it'll be a matter of motivating them with examples and case studies.

If you have some interesting uses of these initializers we'd definitely take a PR for a case study first, and if we find folks are copying and pasting the logic into their code bases a lot we'd definitely consider moving them into the library itself!

Since you opened this PR I believe we opened the discussions tab on this repo. You might be interested in re-sharing your helpers there. Maybe with some examples that can be worked into a case study!

Okay to close this out in favor of those directions?

@rkreutz
Copy link
Author

rkreutz commented Mar 19, 2021

hey @stephencelis,

yeah makes total sense, I'll open a thread on the discussion tab with these, no problem. Thanks for the clarification.

I'll close this now.

@rkreutz rkreutz closed this Mar 19, 2021
@rkreutz
Copy link
Author

rkreutz commented Mar 19, 2021

#450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants