1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/public/js/stores/FeatureToggleActions.js
Anders Olsen Sandvik a96a9f38ce #108 Add eslint-config-spt and remove jshint (#111)
* #108 Add eslint-config-spt

* #108 Ignore bundle.js file

* #108 Change eslint ignore path to a glob file

* Remove jshint and follow more of eslint rules
2020-02-20 08:30:24 +01:00

74 lines
1.9 KiB
JavaScript

var Reflux = require("reflux");
var Server = require('./FeatureToggleServerFacade');
var FeatureToggleActions = Reflux.createActions({
'init': { asyncResult: true },
'initArchive': { asyncResult: true },
'create': { asyncResult: true },
'update': { asyncResult: true },
'archive': { asyncResult: true },
'revive': { asyncResult: true }
});
FeatureToggleActions.init.listen(function() {
Server.getFeatures(function(error, features) {
if (error) {
this.failed(error);
} else {
this.completed(features);
}
}.bind(this));
});
FeatureToggleActions.initArchive.listen(function() {
Server.getArchivedFeatures(function(error, archivedToggles) {
if (error) {
this.failed(error);
} else {
this.completed(archivedToggles);
}
}.bind(this));
});
FeatureToggleActions.create.listen(function(feature) {
Server.createFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
}.bind(this));
});
FeatureToggleActions.update.listen(function(feature) {
Server.updateFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
}.bind(this));
});
FeatureToggleActions.archive.listen(function(feature) {
Server.archiveFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
}.bind(this));
});
FeatureToggleActions.revive.listen(function(feature) {
Server.reviveFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
}.bind(this));
});
module.exports = FeatureToggleActions;