-
Notifications
You must be signed in to change notification settings - Fork 139
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
combineReducers #66
Comments
Hmm - do you have an example of where this is needed? function combineReducers(...fns) {
return (...args) => Object.assign(...fns.map( fn => fn(...args) );
} |
I think no need for a combine reducers.
export default {
one (state) {
// do what?
},
two (state) {
// do what?
}
};
export default {
one (state) {
// do what?
},
two (state) {
// do what?
}
};
import someActions from './someActions';
import anotherActions from './anotherActions';
export default {
...someActions,
...anotherActions
};
import createStore from 'unistore';
import actions from './actions';
const store = createStore({
// what?
});
const actions = store => ({ ...actions });
export { actions };
export default store; now you can access them. import { Provider, connect } from 'unistore/preact';
import store, { actions } from './store';
const App = connect('count', actions)(
({ count, increment }) => (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</div>
)
)
export default () => (
<Provider store={store}>
<App />
</Provider>
) |
@aprilmintacpineda in this case we connect all our app actions into out component. Sometimes we'd like to have a subset of actions like connect(props, {...auth, ...catalog})(props => (...)) because not every screen/component needs all set of actions of our app. props => {
let {login, logout} = useActions(auth)
let {fetch} = useActions(catalog)
} |
Hello! Tell me, please, how i can join reducers, like "combineReducers" in Redux?
The text was updated successfully, but these errors were encountered: