mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-05 02:30:13 +00:00
36 lines
698 B
JavaScript
36 lines
698 B
JavaScript
'use strict';
|
|
|
|
var _ = require('underscore'),
|
|
Reflux = require('reflux'),
|
|
ProjectActions = require('../actions/project'),
|
|
resources = require('../resources'),
|
|
resource = resources.projects;
|
|
|
|
var Store = Reflux.createStore({
|
|
listenables: ProjectActions,
|
|
project: {},
|
|
|
|
getInitialState: function() {
|
|
return this.project;
|
|
},
|
|
|
|
onChange: function(data, action) {
|
|
this.trigger(data.project);
|
|
},
|
|
|
|
init: function() {
|
|
resource.subscribe('change', this.onChange);
|
|
},
|
|
|
|
onRead: function(params) {
|
|
var self = this;
|
|
resource.sync('read', params, function(err, project) {
|
|
if (err) throw err;
|
|
self.project = project;
|
|
self.trigger(self.project);
|
|
});
|
|
}
|
|
});
|
|
|
|
module.exports = Store;
|