Reusable ducks?
See original GitHub issueHow would you suggest making a duck that supports multiple instances?
(And by “duck”, of course I mean a reducer bundle such as the ones under src/redux/modules
.)
For example, counter.js
is the logic behind the “You have clicked me X times” button on the home route. What if I want three of those buttons?
I can add three instances of its reducer to the store:
export default combineReducers({
auth,
counterLeft: counter,
counterCenter: counter,
counterRight: counter,
form,
info,
widgets
});
How would you hook up each CounterButton
to the right property, and how would you direct the duck’s actions to the correct reducer instance?
Thanks for this repository!
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Diaper Duck - Amazon.com
Duck Diapers, Chicken Diapers, Special Diapers for Poultry, Chicken, Duck and Goose Waterproof, Adjustable, Washable and Reusable Diapers,Poultry Supplies, ...
Read more >Flock of Ducks Reusable Stencil many Sizes - Etsy
250 micron/10mil Mylar: Flexible but sturdy, semi-rigid Polyester material. Milky white and glossy surface with medium transparency. Washable and reusable.
Read more >Reusable Goose Diaper - Pinterest
DIAPERS - Goose, Duck, Gosling/Duckling, Chicken, Bantam - DIAPERS $7 - $40. UPDATED Dec 2016 Product List (scroll down for photos and item...
Read more >OREGON DUCKS, BONE CHINA COFFEE MUG AND ... - eBay
ONE DUCKS, 18oz TALL, BONE CHINA, COFFEE MUG FROM DUCKHOUSE SPORTS. ... OREGON DUCKS, BONE CHINA COFFEE MUG AND 20 REUSABLE CUP CLOSEOUT...
Read more >Reusable Tie Straps - Duck Brand
Duck Max Strength Reusable Tie Straps feature a durable rubber polymer that can withstand exposure to a wide range of chemicals and extreme...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This question intrigued me so much that I wrote a whole new library, multireducer, to handle this use case.
I’m not sure how often something like this will come in handy in a production app, but the inability to use the same simple reducer in multiple places on the Redux state tree seemed like a hole in Redux functionality that needed patching. @gaearon, could you give that library a quick glance and let me know if I’m way off base?
It does not “duplicate” them—you can generate them exactly the same way like you generate the reducers. I didn’t want to introduce too much indirection to examples because you often want to put business logic into action creators: for example, they may exit early based on different conditions, or do different things on success.