1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/packages/unleash-frontend/public/js/stores/StrategyActions.js

42 lines
957 B
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
2016-06-18 21:55:46 +02:00
const Reflux = require('reflux');
2016-06-18 21:53:18 +02:00
const StrategyAPI = require('./StrategyAPI');
2015-03-17 22:01:46 +01:00
2016-06-18 21:53:18 +02:00
const StrategyActions = Reflux.createActions({
init: { asyncResult: true },
create: { asyncResult: true },
remove: { asyncResult: true },
2015-03-17 22:01:46 +01:00
});
StrategyActions.init.listen(function() {
2016-06-18 21:53:18 +02:00
StrategyAPI.getStrategies((err, strategies) => {
if (err) {
2015-03-17 22:52:10 +01:00
this.failed(err);
} else {
this.completed(strategies);
}
2016-06-18 21:53:18 +02:00
});
2015-03-17 22:52:10 +01:00
});
StrategyActions.create.listen(function(feature) {
2016-06-18 21:53:18 +02:00
StrategyAPI.createStrategy(feature, err => {
if (err) {
2015-03-17 22:01:46 +01:00
this.failed(err);
} else {
this.completed(feature);
}
2016-06-18 21:53:18 +02:00
});
2015-03-17 22:01:46 +01:00
});
StrategyActions.remove.listen(function(feature) {
2016-06-18 21:53:18 +02:00
StrategyAPI.removeStrategy(feature, err => {
if (err) {
2015-03-17 22:01:46 +01:00
this.failed(err);
} else {
this.completed(feature);
}
2016-06-18 21:53:18 +02:00
});
2015-03-17 22:01:46 +01:00
});
module.exports = StrategyActions;