Skip to content

Instantly share code, notes, and snippets.

@iongion
Last active May 13, 2016 08:57
Show Gist options
  • Save iongion/0ba4980ed1bdeef2ab31241e0c859ece to your computer and use it in GitHub Desktop.
Save iongion/0ba4980ed1bdeef2ab31241e0c859ece to your computer and use it in GitHub Desktop.
// entry point
// node
// vendors
import 'babel-polyfill';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
// project
import configureStore from './store/configureStore';
import AppPage from './containers/pages/App';
import HomePage from './containers/pages/Home';
export default class EntryPoint {
boot(node) {
this.store = configureStore({
configuration: {
video: {
width: 1280,
height: 720,
},
},
domain: {},
});
this.history = syncHistoryWithStore(hashHistory, this.store);
this.renderTo(node);
return this;
}
renderTo(node) {
render(
<Provider store={this.store}>
<Router history={this.history}>
<Route path="/" component={AppPage}>
<IndexRoute component={HomePage} />
<Route path="/home" component={HomePage} />
</Route>
</Router>
</Provider>
,
node
);
return this;
}
}
// reducers
// node
// vendors
import { routerReducer } from 'react-router-redux';
import { combineReducers } from 'redux';
import _ from 'lodash';
// project
import * as ActionTypes from '../actions';
function configuration(state, action) {
console.debug('configuration reducer called', state, action);
switch (action.type) {
case ActionTypes.CONFIGURE_APP:
return state;
default:
return state;
}
}
function domain(state = {}, action) {
console.debug('domain reducer called', state, action);
switch (action.type) {
default:
return state;
}
}
/*
export default function combined(state, action) {
return {
configuration: configuration(state.configuration, action),
domain: domain(state.domain, action),
routing: routerReducer,
};
}
*/
export default combineReducers({
routing: routerReducer,
configuration,
domain,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment