1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-09 00:18:26 +01:00

Added poller to keep the store in sync with server.

This commit is contained in:
Ivar Conradi Østhus 2015-03-05 17:55:21 +01:00
parent 827faba438
commit d495bb1829
2 changed files with 9 additions and 3 deletions

View File

@ -40,10 +40,11 @@ function getFeature(name) {
function getArchivedFeatures() {
return knex
.select(['name', 'description'])
.select(FEATURE_COLUMNS)
.from('features')
.where({archived: 1})
.orderBy('name', 'asc');
.orderBy('name', 'asc')
.map(rowToFeature);
}
@ -115,4 +116,3 @@ module.exports = {
_createFeature: createFeature, // visible for testing
_updateFeature: updateFeature // visible for testing
};

View File

@ -1,6 +1,7 @@
var Reflux = require('reflux');
var FeatureActions = require('./FeatureToggleActions');
var Server = require('./FeatureToggleServerFacade');
var Timer = require('../utils/Timer');
var _featureToggles = [];
var _archivedToggles = [];
@ -14,6 +15,11 @@ var FeatureStore = Reflux.createStore({
this.listenTo(FeatureActions.archive, this.onArchive);
this.listenTo(FeatureActions.revive, this.onRevive);
this.timer = new Timer(this.loadDataFromServer, 30*1000);
this.timer.start();
},
loadDataFromServer: function() {
Server.getFeatures(function(err, featureToggles) {
this.setToggles(featureToggles);
}.bind(this));