pitaya-launcher/js/store/actions/common.js

27 lines
721 B
JavaScript

var Util = require('../../util');
var LOAD_PROFILE = exports.LOAD_PROFILE = 'LOAD_PROFILE';
var LOAD_PROFILE_SUCCESS = exports.LOAD_PROFILE_SUCCESS = 'LOAD_PROFILE_SUCCESS';
var LOAD_PROFILE_FAILED = exports.LOAD_PROFILE_FAILED = 'LOAD_PROFILE_FAILED';
exports.loadProfile = function(profilePath) {
return function(dispatch, getState) {
dispatch({ type: LOAD_PROFILE, profilePath: profilePath });
return Util.System.loadJSON(profilePath)
.then(function(profile) {
dispatch({ type: LOAD_PROFILE_SUCCESS, profile: profile });
return profile;
})
.catch(function(err) {
dispatch({ type: LOAD_PROFILE_FAILED, error: err });
return err;
})
;
};
};