File tree Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
4
+ // Give us an object to bind all events to. This object should be created
5
+ // before all other objects so it exists when others register event handlers.
6
+ // To register an event handler:
7
+ //
8
+ // require(['base/js/events'], function (events) {
9
+ // events.on("event.Namespace", function () { do_stuff(); });
10
+ // });
11
+
12
+ define ( [ 'base/js/events' , 'base/js/namespace' ] , function ( events , Jupyter ) {
13
+ "use strict" ;
14
+
15
+ // Promise to be resolved when the application is initialized.
16
+ // The value is the name of the app on the current page.
17
+ var app_initialized = new Promise ( function ( resolve , reject ) {
18
+ events . on ( 'app_initialized.NotebookApp' , function ( ) {
19
+ resolve ( 'NotebookApp' ) ;
20
+ } ) ;
21
+ events . on ( 'app_initialized.DashboardApp' , function ( ) {
22
+ resolve ( 'DashboardApp' ) ;
23
+ } ) ;
24
+ } ) ;
25
+
26
+ var promises = {
27
+ app_initialized : app_initialized
28
+ } ;
29
+ Jupyter . promises = promises ;
30
+
31
+ return promises ;
32
+ } ) ;
Original file line number Diff line number Diff line change 20
20
* Instances are created after the loading of this file and might need to be accessed using events:
21
21
* define([
22
22
* 'base/js/namespace',
23
- * 'base/js/events'
24
- * ], function(IPython, events) {
25
- * events.on("app_initialized.NotebookApp", function () {
23
+ * 'base/js/promises'
24
+ * ], function(IPython, promises) {
25
+ * promises.app_initialized.then(function (appName) {
26
+ * if (appName !== 'NotebookApp') return;
26
27
* IPython.keyboard_manager....
27
28
* });
28
29
* });
34
35
*
35
36
* define([
36
37
* 'base/js/namespace',
37
- * 'base/js/events'
38
- * ], function(IPython, events) {
39
- * events.on('app_initialized.NotebookApp', function(){
38
+ * 'base/js/promises'
39
+ * ], function(IPython, promises) {
40
+ * promises.app_initialized.then(function (appName) {
41
+ * if (appName !== 'NotebookApp') return;
40
42
* IPython.toolbar.add_buttons_group([
41
43
* {
42
44
* 'label' : 'run qtconsole',
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ require([
29
29
'base/js/utils' ,
30
30
'base/js/page' ,
31
31
'base/js/events' ,
32
+ 'base/js/promises' ,
32
33
'auth/js/loginwidget' ,
33
34
'notebook/js/maintoolbar' ,
34
35
'notebook/js/pager' ,
@@ -52,6 +53,7 @@ require([
52
53
utils ,
53
54
page ,
54
55
events ,
56
+ promises ,
55
57
loginwidget ,
56
58
maintoolbar ,
57
59
pager ,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ require([
26
26
'base/js/namespace' ,
27
27
'base/js/dialog' ,
28
28
'base/js/events' ,
29
+ 'base/js/promises' ,
29
30
'base/js/page' ,
30
31
'base/js/utils' ,
31
32
'services/config' ,
@@ -41,6 +42,7 @@ require([
41
42
IPython ,
42
43
dialog ,
43
44
events ,
45
+ promises ,
44
46
page ,
45
47
utils ,
46
48
config ,
You can’t perform that action at this time.
0 commit comments