Skip to content

Instantly share code, notes, and snippets.

@mbensch
Last active March 18, 2016 07:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbensch/830af5e065b2d69b1fb7 to your computer and use it in GitHub Desktop.
Save mbensch/830af5e065b2d69b1fb7 to your computer and use it in GitHub Desktop.
import { Module } from '../../core';
import AppContainer from './AppContainer.jsx';
const AppModule = new Module('App');
AppModule
.setInitialState({ counter: 0 })
// This will create Action Types (with normalized names) and Action Creators.
// The application container which is a wrapper around the redux store will
// compose all reducers of registered modules. The module name is used as key in the
// application state.
.on('INCREMENT_COUNTER', (state) => ({ counter: state.counter + 1 }))
.on('DECREMENT_COUNTER', (state) => ({ counter: state.counter - 1 }))
// The container component is the component that talks to the store.
// Module.getContainer() will return an instance of the component that
// is automatically bound to state and actions via react-redux bindings
.setContainer(AppContainer)
// This is the main route to the module's container component
// routes to submodules can be added via Module.addRoutes(route)
// with route being a react-redux-router routes object.
// addRoute() can be called multiple times and all routes will be composed
// into a single routes object.
.setIndexRoute('/');
export default AppModule;
@Strate
Copy link

Strate commented Mar 15, 2016

how do you use a redux-thunk? Inside thunked callback there is only root state, so, module should knows how to get its own state from the root of application. Is it resolved by your module system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment