trc-client-core
Version:
The core of the TRC Client
58 lines (54 loc) • 1.56 kB
JavaScript
var reflux = require('reflux');
var EndpointsActions = require('trc-client-core/src/development/EndpointsActions');
var EndpointsStore = reflux.createStore({
listenables: EndpointsActions,
init: function () {
this._paths = null;
this._requests = {};
},
onFetchAllEndpoints: function () {
},
onFetchAllEndpointsCompleted: function (data) {
this._paths = data.paths;
this._definitions = data.definitions;
this._information = data.info;
this.trigger();
},
onTestEndpointCompleted: function (data) {
this._request = data;
this.trigger();
},
onTestEndpointFailed: function (error) {
// console.log('failed', error, res);
this._request = error;
this.trigger();
},
getAllPaths: function () {
if(this._paths) {
return this._paths;
} else {
EndpointsActions.fetchAllEndpoints();
}
},
getInformation: function () {
return this._information;
},
getDefinitions: function () {
if(this._definitions) {
return this._definitions;
} else {
EndpointsActions.fetchAllEndpoints();
}
},
getRequest: function () {
return this._request;
},
getEndpoint: function (id) {
if(this._paths) {
return this._paths[id];
} else {
EndpointsActions.fetchAllEndpoints();
}
}
});
module.exports = EndpointsStore;