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
2020-02-20 08:30:27 +01:00

42 lines
960 B
JavaScript

'use strict';
const Reflux = require('reflux');
const StrategyAPI = require('./StrategyAPI');
const StrategyActions = Reflux.createActions({
init: { asyncResult: true },
create: { asyncResult: true },
remove: { asyncResult: true },
});
StrategyActions.init.listen(function () {
StrategyAPI.getStrategies((err, strategies) => {
if (err) {
this.failed(err);
} else {
this.completed(strategies);
}
});
});
StrategyActions.create.listen(function (feature) {
StrategyAPI.createStrategy(feature, err => {
if (err) {
this.failed(err);
} else {
this.completed(feature);
}
});
});
StrategyActions.remove.listen(function (feature) {
StrategyAPI.removeStrategy(feature, err => {
if (err) {
this.failed(err);
} else {
this.completed(feature);
}
});
});
module.exports = StrategyActions;