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

42 lines
960 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
});
2016-07-02 11:54:50 +02: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
});
2016-07-02 11:54:50 +02: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
});
2016-07-02 11:54:50 +02: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;