##// END OF EJS Templates
Use load_class in comms instead of callbacks.
Jonathan Frederic -
Show More
@@ -67,7 +67,8 b' define(['
67 var content = msg.content;
67 var content = msg.content;
68 var that = this;
68 var that = this;
69
69
70 var instantiate_comm = function(target) {
70 utils.load_class(content.target_name, content.target_module, this.targets)
71 .then(function(target) {
71 var comm = new Comm(content.target_name, content.comm_id);
72 var comm = new Comm(content.target_name, content.comm_id);
72 that.register_comm(comm);
73 that.register_comm(comm);
73 try {
74 try {
@@ -77,29 +78,7 b' define(['
77 comm.close();
78 comm.close();
78 that.unregister_comm(comm);
79 that.unregister_comm(comm);
79 }
80 }
80 };
81 }, console.error);
81
82 if (content.target_module) {
83 // Load requirejs module for comm target
84 require([content.target_module], function(mod) {
85 var target = mod[content.target_name];
86 if (target !== undefined) {
87 instantiate_comm(target)
88 } else {
89 console.log("Comm target " + content.target_name +
90 " not found in module " + content.target_module);
91 }
92 }, function(err) { console.log(err); });
93 } else {
94 // No requirejs module specified: look for target in registry
95 var f = this.targets[content.target_name];
96 if (f === undefined) {
97 console.log("No such target registered: ", content.target_name);
98 console.log("Available targets are: ", this.targets);
99 return;
100 }
101 instantiate_comm(f)
102 }
103 };
82 };
104
83
105 CommManager.prototype.comm_close = function (msg) {
84 CommManager.prototype.comm_close = function (msg) {
General Comments 0
You need to be logged in to leave comments. Login now