Skip to content

Commit be4e918

Browse files
committed
Simplify callback handler definition for classic notebook.
1 parent 29566e9 commit be4e918

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

widgetsnbextension/src/manager.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -289,36 +289,17 @@ WidgetManager.prototype._get_connected_kernel = function() {
289289
});
290290
};
291291

292+
/**
293+
* Callback handlers for a specific view
294+
*/
292295
WidgetManager.prototype.callbacks = function (view) {
293-
/**
294-
* callback handlers specific a view
295-
*/
296-
var callbacks = {};
296+
var callbacks = widgets.ManagerBase.prototype.callbacks.call(this, view);
297297
if (view && view.options.output) {
298-
// Try to get output handlers
299298
var output = view.options.output;
300-
var handle_output = null;
301-
var handle_clear_output = null;
302-
if (output) {
303-
handle_output = _.bind(output.handle_output, output);
304-
handle_clear_output = _.bind(output.handle_clear_output, output);
299+
callbacks.iopub = {
300+
output: output.handle_output.bind(output),
301+
clear_output: output.handle_clear_output.bind(output)
305302
}
306-
307-
// Create callback dictionary using what is known
308-
var that = this;
309-
callbacks = {
310-
iopub : {
311-
output : handle_output,
312-
clear_output : handle_clear_output,
313-
314-
// Special function only registered by widget messages.
315-
// Allows us to get the cell for a message so we know
316-
// where to add widgets if the code requires it.
317-
get_cell : function () {
318-
return cell;
319-
},
320-
},
321-
};
322303
}
323304
return callbacks;
324305
};

0 commit comments

Comments
 (0)