123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: index.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: index.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>/** @module AutoMate */
- // Import dependencies
- import React from 'react'
- import ReactDOM from 'react-dom'
- import { browserHistory, Router, Route, IndexRoute } from 'react-router'
- import { createStore, combineReducers, bindActionCreators, compose } from 'redux'
- import { Provider, connect } from 'react-redux'
- import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
- // Import the main module and the CSS.
- import Main from './Main'
- import './index.css'
- // Import the submodules.
- import project from './project'
- import registermap from './registermap'
- import demo_module from './demo_module'
- /**
- * Redux Section
- **/
- /** The root reducer is combined from all sub-module reducers. */
- const rootReducer = combineReducers({
- project: project.reducer,
- registermap: registermap.reducer,
- demo_module: demo_module.reducer,
- routing: routerReducer
- })
- console.log('Root reducer:', rootReducer)
- /** The default state is combined from all sub-module states. */
- const defaultState = {
- project: project.state,
- registermap: registermap.state,
- demo_module: demo_module.state
- }
- console.log('Default state:', defaultState)
- /** The enhancer allows to use Redux development tools in Chrome. */
- const enhancers = compose(
- window.devToolsExtension ? window.devToolsExtension() : f => f
- )
- console.log('Enhancers:', enhancers)
- /** Build the Redux store from the rootReducer, the defualtState and the enhancers. */
- const store = createStore(rootReducer, defaultState, enhancers)
- console.log('store:', store)
- const history = syncHistoryWithStore(browserHistory, store)
- console.log('history:', history)
- /** Collect the action creators from all modules in actionCreators */
- const actionCreators = { project: project.actions, registermap: registermap.actions, demo_module: demo_module.actionCreators }
- /** Creates a function */
- function mapStateToProps (state) {
- const propState = {}
- Object.keys(state).forEach(key => {
- propState[key] = state[key]
- })
- console.log('Mapping state to props:', state, propState)
- return propState
- }
- function mapDispatchToProps (dispatch) {
- const boundActionCreators = {}
- Object.keys(actionCreators).forEach(key => {
- boundActionCreators[`${key}Actions`] = bindActionCreators(actionCreators[key], dispatch)
- })
- console.log('Mapping dispatch to props:', dispatch, boundActionCreators)
- return boundActionCreators
- }
- const App = connect(mapStateToProps, mapDispatchToProps)(Main)
- /**
- * React-Router Section
- **/
- /** Combine the routes from all modules. */
- const router = (
- <Provider store={store}>
- <Router history={history}>
- <Route component={App}>
- <Route path='/'>
- <IndexRoute component={demo_module.components.DemoModule} />
- <Route path='/project/:projectId' component={project.components.Project} />
- <Route path='/project' component={project.components.Project} />
- <Route path='/registermap/:registermapId' component={registermap.components.Registermap} />
- <Route path='/registermap' component={registermap.components.Registermap} />
- </Route>
- {demo_module.routes}
- <Route path='/login' />
- </Route>
- </Router>
- </Provider>
- )
- /**
- * Render the app
- **/
- ReactDOM.render(
- router,
- document.getElementById('root')
- )
- </code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-AutoMate.html">AutoMate</a></li><li><a href="module-demo_module.html">demo_module</a></li><li><a href="module-demo_module_components_index.html">demo_module/components/index</a></li><li><a href="module-demo_module_constants.html">demo_module/constants</a></li><li><a href="module-demo_module_initialData.html">demo_module/initialData</a></li><li><a href="module-demo_module_state.html">demo_module/state</a></li><li><a href="module-project.html">project</a></li><li><a href="module-project_components.html">project/components</a></li><li><a href="module-project_state.html">project/state</a></li><li><a href="module-registermap.html">registermap</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Mar 14 2017 18:34:23 GMT+0100 (W. Europe Standard Time)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|