Refactoring + mise en place store Redux
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
exports.mauncher = require('./launcher');
|
||||
exports.launcher = require('./launcher');
|
||||
exports.edit = require('./edit');
|
||||
|
@ -4,20 +4,48 @@ 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';
|
||||
|
||||
var RUN_APP = exports.RUN_APP = 'RUN_APP';
|
||||
var RUN_APP_SUCCESS = exports.RUN_APP_SUCCESS = 'RUN_APP_SUCCESS';
|
||||
var RUN_APP_FAILED = exports.RUN_APP_FAILED = 'RUN_APP_FAILED';
|
||||
|
||||
exports.loadProfile = function(profilePath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
||||
dispatch({ type: LOAD_PROFILE });
|
||||
dispatch({ type: LOAD_PROFILE, profilePath: profilePath });
|
||||
|
||||
return Util.System.loadJSONFile(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;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
exports.runApp = function(execPath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
||||
dispatch({ type: RUN_APP, execPath: execPath });
|
||||
|
||||
return Util.System.runApp(execPath)
|
||||
.then(function() {
|
||||
dispatch({ type: RUN_APP_SUCCESS, execPath: execPath });
|
||||
return execPath;
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: RUN_APP_FAILED, error: err });
|
||||
return err;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user