electron-devtools-vendor
Version:
<div align="center"> <h2>electron-devtools-vendor</h2> <img alt="MIT" src="https://img.shields.io/github/license/BlackHole1/electron-devtools-vendor?color=9cf&style=flat-square"> <img alt="GitHub repo size" src="https://img.shields.io/github/r
61 lines (48 loc) • 2.45 kB
JavaScript
define(["backbone", "underscore", "backboneAgentClient"],
function(Backbone, _, backboneAgentClient) {
var AppComponentAction = Backbone.Model.extend({
component: undefined, // AppComponent child object
// index of the action (relative to those of the component)
index: undefined,
// see backbone agent for supported attributes
initialize: function(attributes, options) {
},
// TODO: same as AppComponent, refactor to have a base Model
url: function() {
var collectionUrl = (typeof this.collection.url == 'function') ?
this.collection.url() : this.collection.url;
return collectionUrl+'/'+this.index;
},
fetch: function(onComplete) {
var index = this.index;
if (index === undefined) {
throw "The index attribute is undefined.";
}
backboneAgentClient.execFunction(function(componentCategory, componentIndex, index) {
var appComponentInfo = this.appComponentsInfos[componentCategory].at(componentIndex);
var appComponentAction = appComponentInfo.actions.at(index);
return appComponentAction.attributes;
}, [this.component.category, this.component.index, this.index],
_.bind(function(appComponentActionAttributes) { // on executed
setTimeout(_.bind(function() { // prevent UI blocking
// reset attributes
this.clear({silent: true});
this.set(appComponentActionAttributes);
if (onComplete !== undefined) onComplete();
}, this));
}, this));
},
// print the action data on the console
printData: function() {
backboneAgentClient.execFunction(function(componentCategory, componentIndex, index) {
var appComponentInfo = this.appComponentsInfos[componentCategory].at(componentIndex);
var appComponentAction = appComponentInfo.actions.at(index);
console.log(appComponentAction.get('name')+":", appComponentAction.data);
}, [this.component.category, this.component.index, this.index],
_.bind(function(result) { // on executed
// do nothing
}, this));
}
});
return AppComponentAction;
});