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

74 lines
1.9 KiB
JavaScript
Raw Normal View History

var Reflux = require("reflux");
2015-03-16 21:27:56 +01:00
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 }
2015-03-16 21:27:56 +01:00
});
FeatureToggleActions.init.listen(function() {
2015-03-17 22:52:10 +01:00
Server.getFeatures(function(error, features) {
if (error) {
this.failed(error);
} else {
this.completed(features);
}
2015-03-17 22:52:10 +01:00
}.bind(this));
});
FeatureToggleActions.initArchive.listen(function() {
2015-03-17 22:52:10 +01:00
Server.getArchivedFeatures(function(error, archivedToggles) {
if (error) {
this.failed(error);
} else {
this.completed(archivedToggles);
}
2015-03-17 22:52:10 +01:00
}.bind(this));
});
FeatureToggleActions.create.listen(function(feature) {
2015-03-16 21:27:56 +01:00
Server.createFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
2015-03-16 21:27:56 +01:00
}.bind(this));
});
FeatureToggleActions.update.listen(function(feature) {
2015-03-16 21:27:56 +01:00
Server.updateFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
2015-03-16 21:27:56 +01:00
}.bind(this));
});
FeatureToggleActions.archive.listen(function(feature) {
2015-03-16 21:27:56 +01:00
Server.archiveFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
2015-03-16 21:27:56 +01:00
}.bind(this));
});
FeatureToggleActions.revive.listen(function(feature) {
2015-03-16 21:27:56 +01:00
Server.reviveFeature(feature, function(error) {
if (error) {
this.failed(error);
} else {
this.completed(feature);
}
2015-03-16 21:27:56 +01:00
}.bind(this));
});
module.exports = FeatureToggleActions;