Source: src/actions.js

/** Outsourced definition of the actions and simple action creators for simple actions.
 * @module Actions
 * @todo allowed values
 */

const Promise = require('promise');
const writeConfig = require('./utility/config.js').write;

/**
 * Actions
 * The action definitions.
 */
let actions = {
    UPDATE_CONFIG: 'UPDATE_CONFIG',
    REQUEST_START: 'REQUEST_START',
    SET_STARTED: 'SET_STATED',
    REQUEST_STOP: 'REQUEST_STOP',
    SET_STOPPED: 'SET_STOPPED',
    REQUEST_RESTART: 'REQUEST_RESTART',
    SET_ERROR: 'SET_ERROR',
    TRY_RECONECT: 'TRY_RECONNECT'
};

/**
 * Trivial Action Creators
 */
let creators = {};

creators.updateConfig = function(update) {
    return function(dispatch, getState) {
        dispatch({
            type: actions.UPDATE_CONFIG,
            data: update
        });

        return writeConfig(getState());
    };
};

creators.requestStart = function() {
    return {
        type: actions.REQUEST_START
    };
};

creators.requestStop = function() {
    return {
        type: actions.REQUEST_STOP
    };
};

creators.setStarted = function() {
    return {
        type: actions.SET_STARTED
    };
};

creators.setStopped = function() {
    return {
        type: actions.SET_STOPPED
    };
};

creators.requestRestart = function() {
    return {
        type: actions.REQUEST_RESTART
    };
};

creators.setError = function(error) {
    return {
        type: actions.SET_ERROR,
        data: error
    };
};

creators.tryReconnect = function() {
    return {
	type: actions.TRY_RECONECT
    };
};

module.exports = {
    actions,
    creators
};