Treat Redux like a rack — mount reducers like components
withReducer('foo', (foo, action) => foo)(Component)
withReducer({
foo(foo, action) {
// … reducer logic …
},
bar(bar, action) {
// … reducer logic …
},
})
withReducer({
bar(bar, action) {
// … reducer logic …
},
// Runs after, on nested value
'bar.baz': (baz, action) => {
// … reducer logic …
},
})
withReducer({
// Run for each list item
'foos[]': (item, action) => {
// … reducer logic …
},
// Run after, for each item property
'foos[].ball': (property, action) => {
// … reducer logic …
},
})
withReducer((state, action) =>
// time for something completely different
)
-
withReducer signature
- simple
(key, reducer)
- combined
{ foo, bar }
- nested
{ bar, bar.baz }
- iterative
{ foos[], foos[].prop }
- global,
window.throw(caution)
- simple
-
Development
- stable
- active
- wanting
- in need of intervention
- delinquent neglect