1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/StrategyActions.js

41 lines
995 B
JavaScript
Raw Normal View History

2015-03-17 22:01:46 +01:00
var Reflux = require("reflux");
var StrategyAPI = require('./StrategyAPI');
var StrategyActions = Reflux.createActions({
'init': { asyncResult: true },
'create': { asyncResult: true },
'remove': { asyncResult: true },
2015-03-17 22:01:46 +01:00
});
StrategyActions.init.listen(function() {
2015-03-17 22:52:10 +01:00
StrategyAPI.getStrategies(function(err, strategies) {
if (err) {
2015-03-17 22:52:10 +01:00
this.failed(err);
} else {
this.completed(strategies);
}
}.bind(this));
});
StrategyActions.create.listen(function(feature) {
2015-03-17 22:01:46 +01:00
StrategyAPI.createStrategy(feature, function(err) {
if (err) {
2015-03-17 22:01:46 +01:00
this.failed(err);
} else {
this.completed(feature);
}
}.bind(this));
});
StrategyActions.remove.listen(function(feature) {
2015-03-17 22:01:46 +01:00
StrategyAPI.removeStrategy(feature, function(err) {
if (err) {
2015-03-17 22:01:46 +01:00
this.failed(err);
} else {
this.completed(feature);
}
}.bind(this));
});
module.exports = StrategyActions;