doccam-pi/main_new.js~
Hiro Protagonist d451ea6dd4 compatibility
2017-04-27 17:43:06 +12:00

55 lines
1.9 KiB
JavaScript

/**
* @module Main
* @description The main module and entry point.
*/
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
///////////////////////////////////////////////////////////////////////////////
// Redux //
///////////////////////////////////////////////////////////////////////////////
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { Object } config Configuration of the camera.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false
},
config: {}
};
// Reducer
const reducer = require('./src/reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk));
// The dispatch function for the state.
const dispatch = store.dispatch;
// The function to get the state.
const getState = store.getState;
// Simple Action creators
const creators = require('./src/actions.js').creators;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// Load the Config
store.dispatch(creators.updateConfig());
console.log(store.getState());
//const Commander = require('./src/commander.js')(getState);