question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How 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:closed
  • Created 8 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
erikrascommented, Sep 28, 2015

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?

0reactions
gaearoncommented, Sep 29, 2015

I did look at the paginate example, but was thrown off because it duplicates action creators for each instance - for example, loadStarred and loadStargazers.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found