mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 22:45:07 +00:00
36 lines
718 B
JavaScript
36 lines
718 B
JavaScript
'use strict';
|
|
|
|
define([
|
|
'underscore',
|
|
'reflux', 'app/actions/build', 'app/resources'
|
|
], function(_, Reflux, BuildActions, resources) {
|
|
var 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);
|
|
});
|
|
}
|
|
});
|
|
|
|
return Store;
|
|
});
|