Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a promise for app_initialized event. #2710

Merged
merged 2 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions notebook/static/base/js/promises.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// Give us an object to bind all events to. This object should be created
// before all other objects so it exists when others register event handlers.
// To register an event handler:
//
// require(['base/js/events'], function (events) {
// events.on("event.Namespace", function () { do_stuff(); });
// });

define(['base/js/events', 'base/js/namespace'], function(events, Jupyter) {
"use strict";

// Promise to be resolved when the application is initialized.
// The value is the name of the app on the current page.
var app_initialized = new Promise(function(resolve, reject) {
events.on('app_initialized.NotebookApp', function() {
resolve('NotebookApp');
});
events.on('app_initialized.DashboardApp', function() {
resolve('DashboardApp');
});
});

var promises = {
app_initialized: app_initialized
};
Jupyter.promises = promises;

return promises;
});
2 changes: 2 additions & 0 deletions notebook/static/notebook/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require([
'base/js/utils',
'base/js/page',
'base/js/events',
'base/js/promises',
'auth/js/loginwidget',
'notebook/js/maintoolbar',
'notebook/js/pager',
Expand All @@ -52,6 +53,7 @@ require([
utils,
page,
events,
promises,
loginwidget,
maintoolbar,
pager,
Expand Down
2 changes: 2 additions & 0 deletions notebook/static/tree/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require([
'base/js/namespace',
'base/js/dialog',
'base/js/events',
'base/js/promises',
'base/js/page',
'base/js/utils',
'services/config',
Expand All @@ -41,6 +42,7 @@ require([
IPython,
dialog,
events,
promises,
page,
utils,
config,
Expand Down