Show More
@@ -120,6 +120,11 b' define([' | |||
|
120 | 120 | this.target_name = target_name; |
|
121 | 121 | this.comm_id = comm_id || utils.uuid(); |
|
122 | 122 | this._msg_callback = this._close_callback = null; |
|
123 | ||
|
124 | var that = this; | |
|
125 | this.msg_promise = new Promise(function(resolve, reject) { | |
|
126 | that.resolve_msg_promise = resolve; | |
|
127 | }); | |
|
123 | 128 | }; |
|
124 | 129 | |
|
125 | 130 | // methods for sending messages |
@@ -155,6 +160,7 b' define([' | |||
|
155 | 160 | |
|
156 | 161 | Comm.prototype.on_msg = function (callback) { |
|
157 | 162 | this._register_callback('msg', callback); |
|
163 | this.resolve_msg_promise(); | |
|
158 | 164 | }; |
|
159 | 165 | |
|
160 | 166 | Comm.prototype.on_close = function (callback) { |
@@ -175,7 +181,10 b' define([' | |||
|
175 | 181 | }; |
|
176 | 182 | |
|
177 | 183 | Comm.prototype.handle_msg = function (msg) { |
|
178 | this._maybe_callback('msg', msg); | |
|
184 | var that = this; | |
|
185 | this.msg_promise.then(function() { | |
|
186 | that._maybe_callback('msg', msg); | |
|
187 | }); | |
|
179 | 188 | }; |
|
180 | 189 | |
|
181 | 190 | Comm.prototype.handle_close = function (msg) { |
General Comments 0
You need to be logged in to leave comments.
Login now