ioof-holdings / redux-dynamic-reducer

Attach reducers to an existing Redux store
BSD 3-Clause "New" or "Revised" License
68 stars 9 forks source link

Questions regarding capabilities #4

Closed flq closed 6 years ago

flq commented 6 years ago

Hello, 2 questions:

mpeyper commented 6 years ago

Is it possible to remove already attached reducers?

Not currently. It would not be difficult to add if you wanted to though. You might start here

Is it possible to attach dynamic reducers Array-Style, e.g. when you have a set of components that can be added or removed list-like...

I don't follow. Can you post an example of what you mean?

flq commented 6 years ago

With regard to removing reducers - is it something you wouldn't mind seeing in your library (a.k.a. PR)?

As to the second question:

Imagine UI components, each with their own reducer, etc., that can be added / removed a bit like rows in a "table" on a main screen. Hence, if we add a new "row", I would want to add the model for an additional row, as well as the corresponding reducer to the reducers, e.g.

store.attachReducers({ 'ui.items[${index}]': { dynamicReducer } } } }) (?)

mpeyper commented 6 years ago

is it something you wouldn't mind seeing in your library (a.k.a. PR)?

I said early on that it would make sense and be pretty easy to do, so as soon as we had the need for it , we'd add it. As it turned out for us, we have never actually needed to remove the reducer.

I would be happy to look at PR for it if you need it. The only reservation I would have is that we are looking at open-sourcing a new library soon that deprecated this one, so any effort spent here will be short lived.

You can see a preview of what the new library will look like when setting up the store and when enhancing a component in a presentation I did at a local meet up.

As to the second question

No, there is no current functionality for this. You might be able to hack something together using the `createInstance' functionality, but be careful not to create instances within the render function.

Other than that, I'm open to hearing suggestions for how the API could accomodate this.

mpeyper commented 6 years ago

I'm closing this due to inactivity. Still happy to discuss any API enhancements people want.