Jupyter Notebook Frontend Extension wait for other Frontend Extension

49 views
Skip to first unread message

Zelphir Kaltstahl

unread,
May 18, 2017, 10:26:52 AM5/18/17
to Project Jupyter
Hi,

I am writing some extensions which I need. The extensions have different purposes, but I'd like to ensure, that one of them has run before the other ones are run.

What is a good way to do this? (no busy wait if not necessary)

In each of the extensions I am listening for the notebook to be loaded like this:


/////////// BEGIN
function load_ipython_extension() {
            if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
                if (!initialized) {
                    init();
                }
            } else {
                if (!initialized) {
                    events.on('notebook_loaded.Notebook', () => {
                        init();
                    });
                }
            }
        }
/////////// END

Then in init happens the actual work.
This was a practice suggested in some issue on Github and I already adopted that, but how can I be sure that extension A runs before extensions B, C and D, regardless of the specifics of what they do? Is there some event I could listen to, which contains the name of the extension? Maybe something like:

/////////// BEGIN
events.on('extension_loaded.ExtensionName')
/////////// END

Or a simple way to introduce such an event myself, without changing the notebook source code itself, maybe some generic event sending, where I can put in any name I want for the event and then listen for that in the other extensions?

Brian Granger

unread,
May 20, 2017, 12:11:03 AM5/20/17
to Project Jupyter
Yes, the classic notebook is not really setup for multiple runtime
extensions to resolve their runtime dependencies. This dependency
resolution is independent of the code loading on the page through
require.js. We have solved these things with the new extension system
in JupyterLab, but doing it well takes a huge amount of work and would
break the classic notebook APIs. It is my opinion that we are better
off keeping the classic notebook as is in this respect and relying on
JupyterLab when these things are needed.
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+u...@googlegroups.com.
> To post to this group, send email to jup...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/926c0539-e9a1-43d2-aad7-b3128df2936d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgra...@calpoly.edu and elli...@gmail.com
Reply all
Reply to author
Forward
0 new messages