##// END OF EJS Templates
Fixed bug in throttling code.
Jonathan Frederic -
Show More
@@ -160,9 +160,13 b''
160 WidgetManager.prototype.callbacks = function (view) {
160 WidgetManager.prototype.callbacks = function (view) {
161 // callback handlers specific a view
161 // callback handlers specific a view
162 var callbacks = {};
162 var callbacks = {};
163 var cell = view.options.cell;
163 if (view !== undefined &&
164 if (cell !== null) {
164 view !== null &&
165 view.options.cell !== undefined &&
166 view.options.cell !== null) {
167
165 // Try to get output handlers
168 // Try to get output handlers
169 var cell = view.options.cell;
166 var handle_output = null;
170 var handle_output = null;
167 var handle_clear_output = null;
171 var handle_clear_output = null;
168 if (cell.output_area !== undefined && cell.output_area !== null) {
172 if (cell.output_area !== undefined && cell.output_area !== null) {
@@ -56,6 +56,7 b' function(WidgetManager, Underscore, Backbone){'
56 if (this.comm !== undefined) {
56 if (this.comm !== undefined) {
57 var data = {method: 'custom', content: content};
57 var data = {method: 'custom', content: content};
58 this.comm.send(data, callbacks);
58 this.comm.send(data, callbacks);
59 this.pending_msgs++;
59 }
60 }
60 },
61 },
61
62
@@ -158,7 +159,13 b' function(WidgetManager, Underscore, Backbone){'
158
159
159 // Only sync if there are attributes to send to the back-end.
160 // Only sync if there are attributes to send to the back-end.
160 if (_.size(attrs) > 0) {
161 if (_.size(attrs) > 0) {
161 var callbacks = options.callbacks || {};
162
163 // If this message was sent via backbone itself, it will not
164 // have any callbacks. It's important that we create callbacks
165 // so we can listen for status messages, etc...
166 var callbacks = options.callbacks || this.callbacks();
167
168 // Check throttle.
162 if (this.pending_msgs >= this.msg_throttle) {
169 if (this.pending_msgs >= this.msg_throttle) {
163 // The throttle has been exceeded, buffer the current msg so
170 // The throttle has been exceeded, buffer the current msg so
164 // it can be sent once the kernel has finished processing
171 // it can be sent once the kernel has finished processing
@@ -181,8 +188,7 b' function(WidgetManager, Underscore, Backbone){'
181
188
182 } else {
189 } else {
183 // We haven't exceeded the throttle, send the message like
190 // We haven't exceeded the throttle, send the message like
184 // normal. If this is a patch operation, just send the
191 // normal.
185 // changes.
186 var data = {method: 'backbone', sync_data: attrs};
192 var data = {method: 'backbone', sync_data: attrs};
187 this.comm.send(data, callbacks);
193 this.comm.send(data, callbacks);
188 this.pending_msgs++;
194 this.pending_msgs++;
@@ -176,8 +176,8 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
176 },
176 },
177
177
178 handleChanging: function(e) {
178 handleChanging: function(e) {
179 // Handles and validates user input.
179 // Handles user input.
180
180
181 // Calling model.set will trigger all of the other views of the
181 // Calling model.set will trigger all of the other views of the
182 // model to update.
182 // model to update.
183 this.model.set('value', e.target.value, {updated_view: this});
183 this.model.set('value', e.target.value, {updated_view: this});
General Comments 0
You need to be logged in to leave comments. Login now