Skip to content

Commit

Permalink
Use promise instead of event (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffyjefflabs committed Mar 3, 2019
1 parent 022a43d commit d6b9c56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions jupyter_nbgallery/static/docker-gallery-notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ define(function() {
require(['base/js/utils','services/config'], function(utils,configmod) {
if (gallery_notebook_loaded == false) {
gallery_notebook_loaded = true;
console.log('loading gallery notebook extension');

// Load extensions hosted at nbgallery
var cconfig = new configmod.ConfigSection('common',{base_url: utils.get_body_data("baseUrl")});
Expand Down Expand Up @@ -56,15 +57,11 @@ define(function() {
};

var load_ipython_extension = function() {
require(['base/js/events'], function(events) {
// For some reason, we miss the notebook_loaded event for large notebooks
// so the kernel hook is our safety.
// If we already missed the event, call our load function explicitly.
if (Jupyter.notebook.kernel.is_connected()) {
require(['base/js/promises'], function(promises) {
// Load our extension once the notebook has loaded
promises.notebook_loaded.then(function() {
load_gallery_notebook();
}
events.on("kernel_ready.Kernel", load_gallery_notebook);
events.on("notebook_loaded.Notebook", load_gallery_notebook);
});
});
};

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

setup(
name='jupyter-nbgallery',
version='0.2.5',
version='0.2.6',
description='Jupyter extensions to add nbgallery integration',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit d6b9c56

Please sign in to comment.