Commit ea9cbb0c authored by Romain Courteaud's avatar Romain Courteaud

No need to create a monitor if no service/job will be used.

parent 27095855
...@@ -448,10 +448,12 @@ ...@@ -448,10 +448,12 @@
RenderJSGadget.prototype.__required_js_list = []; RenderJSGadget.prototype.__required_js_list = [];
function deleteGadgetMonitor(g) { function deleteGadgetMonitor(g) {
if (g.hasOwnProperty('__monitor')) {
g.__monitor.cancel(); g.__monitor.cancel();
delete g.__monitor; delete g.__monitor;
g.__job_list = []; g.__job_list = [];
} }
}
function createGadgetMonitor(g) { function createGadgetMonitor(g) {
g.__monitor = new Monitor(); g.__monitor = new Monitor();
...@@ -588,6 +590,10 @@ ...@@ -588,6 +590,10 @@
} }
function startService(gadget) { function startService(gadget) {
if ((gadget.constructor.__service_list.length === 0) &&
(!gadget.constructor.__job_declared)) {
return;
}
createGadgetMonitor(gadget); createGadgetMonitor(gadget);
gadget.__monitor.monitor(new RSVP.Queue() gadget.__monitor.monitor(new RSVP.Queue()
.push(function monitorAllServiceList() { .push(function monitorAllServiceList() {
...@@ -612,6 +618,7 @@ ...@@ -612,6 +618,7 @@
// of a function inside a service // of a function inside a service
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
RenderJSGadget.declareJob = function declareJob(name, callback) { RenderJSGadget.declareJob = function declareJob(name, callback) {
this.__job_declared = true;
this.prototype[name] = function triggerJob() { this.prototype[name] = function triggerJob() {
var context = this, var context = this,
argument_list = arguments; argument_list = arguments;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment