1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00

Added init-error events

This commit is contained in:
Ivar Conradi Østhus 2015-03-17 20:34:19 +01:00
parent 8ba685b67a
commit 945f4761d5
2 changed files with 43 additions and 34 deletions

View File

@ -1,5 +1,6 @@
var Reflux = require('reflux');
var FeatureActions = require('./FeatureToggleActions');
var ErrorActions = require('./ErrorActions');
var Timer = require('../utils/Timer');
var Server = require('./FeatureToggleServerFacade');
var filter = require('lodash/collection/filter');
@ -9,7 +10,6 @@ var _archivedToggles = [];
// Creates a DataStore
var FeatureStore = Reflux.createStore({
//The store should be split in two: toggleStore && archivedToggleStore!
// Initial setup
init: function() {
@ -23,8 +23,15 @@ var FeatureStore = Reflux.createStore({
loadDataFromServer: function() {
//TODO: this should not be part of the store!
Server.getArchivedFeatures(function(err, archivedToggles) {
if(err) {
ErrorActions.error(err);
return;
} else {
_archivedToggles = archivedToggles;
this.trigger();
this.trigger(_archivedToggles);
}
}.bind(this));
},

View File

@ -1,5 +1,6 @@
var Reflux = require('reflux');
var FeatureActions = require('./FeatureToggleActions');
var ErrorActions = require('./ErrorActions');
var Server = require('./FeatureToggleServerFacade');
var Timer = require('../utils/Timer');
var filter = require('lodash/collection/filter');
@ -20,7 +21,7 @@ var FeatureStore = Reflux.createStore({
this.listenTo(FeatureActions.revive.completed, this.onRevive);
//TODO: this should not be part of the store!
this.timer = new Timer(this.loadDataFromServer, 3*1000);
this.timer = new Timer(this.loadDataFromServer, 30*1000);
this.timer.start();
},
@ -28,6 +29,7 @@ var FeatureStore = Reflux.createStore({
//TODO: this should not be part of the store!
Server.getFeatures(function(err, featureToggles) {
if(err) {
ErrorActions.error(err);
return;
} else {
this.setToggles(featureToggles);