cerebral-modules
Create cerebral modules that can be reused, shared, imported or just simply keep your app tidy.
Creating a module
A module needs to export the following:
export default {
name: 'uniqueModuleName',
init(controller) {
},
routes(controller) {
},
Component: ModuleIndexComponent
}
Loading modules
From your main.js
import controller from './controller';
import external form 'external-node-module';
import home from './modules/home';
import notFound from './modules/notFound';
import loadModules from 'cerebral-react-modules/load';
loadModules(controller, [ external, home, notFound ]);
Route Signals
In your module routing signals you need to specify which module should be rendered. This can be done using the setActiveModule
action.
import setActiveModule from 'cerebral-react-modules/setActiveModule';
controller.signal('home.routed', [
setActiveModule('home')
]);
Contribute
Fork repo
npm install
npm run dev
runs dev mode which watches for changes and auto lints, tests and buildsnpm test
runs the testsnpm run lint
lints the codenpm run build
compiles es6 to es5