diff --git a/src/App.js b/src/App.js index c25808a..be13f91 100644 --- a/src/App.js +++ b/src/App.js @@ -31,6 +31,8 @@ export class App extends Component { window.clientWS.addEventListener('open', this.onWebSocketOpen); window.clientWS.addEventListener('message', console); window.clientWS.addEventListener('close', this.onWebSocketClose); + + console.info(this.context); } componentWillUnmount () { diff --git a/src/configureStore.js b/src/configureStore.js new file mode 100644 index 0000000..04acba5 --- /dev/null +++ b/src/configureStore.js @@ -0,0 +1,14 @@ +/** + * Redux setup + */ +import { combineReducers, createStore } from 'redux'; + +import * as reducers from './reducers'; + +const configureStore = (defaultState = {}) => { + return createStore(combineReducers({ + ...reducers, + }), defaultState); +}; + +export default configureStore; diff --git a/src/index.js b/src/index.js index 36e3afc..94afb66 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,13 @@ -import { App } from './App'; import { render } from 'inferno'; +import { Provider } from 'inferno-redux'; -render(, document.getElementById('app')); +import configureStore from './configureStore'; +import { App } from './App'; + +const store = configureStore(); + +render(( + + + +), document.getElementById('app')); diff --git a/src/reducers/index.js b/src/reducers/index.js new file mode 100644 index 0000000..3d6b493 --- /dev/null +++ b/src/reducers/index.js @@ -0,0 +1 @@ +export * from './wsReducer'; diff --git a/src/reducers/wsReducer.js b/src/reducers/wsReducer.js new file mode 100644 index 0000000..6d359d2 --- /dev/null +++ b/src/reducers/wsReducer.js @@ -0,0 +1,13 @@ +/** + * Reducer for websocket-based actions + * + * @param {object} state + * @param {object} action + * @return {object} newState + */ +export const wsReducer = (state = {}, action) => { + switch (action.type) { + default: + return state; + } +};