mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-05 10:50:14 +00:00
35 lines
719 B
JavaScript
35 lines
719 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var _ = require('underscore'),
|
||
|
Reflux = require('reflux'),
|
||
|
BuildActions = require('../actions/build'),
|
||
|
resources = require('../resources'),
|
||
|
resource = resources.builds;
|
||
|
|
||
|
var Store = Reflux.createStore({
|
||
|
listenables: BuildActions,
|
||
|
build: null,
|
||
|
|
||
|
onChange: function(data, action) {
|
||
|
if (this.build && (data.buildId === this.build.id)) {
|
||
|
_(this.build).extend(data.changes);
|
||
|
this.trigger(this.build);
|
||
|
}
|
||
|
},
|
||
|
|
||
|
init: function() {
|
||
|
resource.subscribe('change', this.onChange);
|
||
|
},
|
||
|
|
||
|
onRead: function(id) {
|
||
|
var self = this;
|
||
|
resource.sync('read', {id: id}, function(err, build) {
|
||
|
if (err) throw err;
|
||
|
self.build = build;
|
||
|
self.trigger(self.build);
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = Store;
|