Show More
@@ -5,8 +5,7 b' define([' | |||
|
5 | 5 | 'base/js/namespace', |
|
6 | 6 | 'jquery', |
|
7 | 7 | 'codemirror/lib/codemirror', |
|
8 | 'rsvp', | |
|
9 | ], function(IPython, $, CodeMirror, rsvp){ | |
|
8 | ], function(IPython, $, CodeMirror){ | |
|
10 | 9 | "use strict"; |
|
11 | 10 | |
|
12 | 11 | IPython.load_extensions = function () { |
@@ -641,7 +640,7 b' define([' | |||
|
641 | 640 | // Tries to load a class from a module using require.js, if a module |
|
642 | 641 | // is specified, otherwise tries to load a class from the global |
|
643 | 642 | // registry, if the global registry is provided. |
|
644 |
return new |
|
|
643 | return new Promise(function(resolve, reject) { | |
|
645 | 644 | |
|
646 | 645 | // Try loading the view module using require.js |
|
647 | 646 | if (module_name) { |
@@ -664,13 +663,13 b' define([' | |||
|
664 | 663 | |
|
665 | 664 | var resolve_dict = function(d) { |
|
666 | 665 | // Resolve a promiseful dictionary. |
|
667 |
// Returns a single |
|
|
666 | // Returns a single Promise. | |
|
668 | 667 | var keys = Object.keys(d); |
|
669 | 668 | var values = []; |
|
670 | 669 | keys.forEach(function(key) { |
|
671 | 670 | values.push(d[key]); |
|
672 | 671 | }); |
|
673 |
return |
|
|
672 | return Promise.all(values).then(function(v) { | |
|
674 | 673 | d = {}; |
|
675 | 674 | for(var i=0; i<keys.length; i++) { |
|
676 | 675 | d[keys[i]] = v[i]; |
@@ -707,15 +706,15 b' define([' | |||
|
707 | 706 | WrappedError.prototype = Object.create(Error.prototype, {}); |
|
708 | 707 | |
|
709 | 708 | var reject = function(message, log) { |
|
710 |
// Creates a wrappable |
|
|
709 | // Creates a wrappable Promise rejection function. | |
|
711 | 710 | // |
|
712 |
// Creates a function that returns a |
|
|
711 | // Creates a function that returns a Promise.reject with a new WrappedError | |
|
713 | 712 | // that has the provided message and wraps the original error that |
|
714 | 713 | // caused the promise to reject. |
|
715 | 714 | return function(error) { |
|
716 | 715 | var wrapped_error = new WrappedError(message, error); |
|
717 | 716 | if (log) console.error(wrapped_error); |
|
718 |
return |
|
|
717 | return Promise.reject(wrapped_error); | |
|
719 | 718 | }; |
|
720 | 719 | }; |
|
721 | 720 |
@@ -49,6 +49,7 b' require([' | |||
|
49 | 49 | custom |
|
50 | 50 | ) { |
|
51 | 51 | "use strict"; |
|
52 | console.log(promise); | |
|
52 | 53 | |
|
53 | 54 | // compat with old IPython, remove for IPython > 3.0 |
|
54 | 55 | window.CodeMirror = CodeMirror; |
@@ -5,8 +5,7 b' define([' | |||
|
5 | 5 | 'base/js/namespace', |
|
6 | 6 | 'jquery', |
|
7 | 7 | 'base/js/utils', |
|
8 | 'rsvp', | |
|
9 | ], function(IPython, $, utils, rsvp) { | |
|
8 | ], function(IPython, $, utils) { | |
|
10 | 9 | "use strict"; |
|
11 | 10 | |
|
12 | 11 | //----------------------------------------------------------------------- |
@@ -80,7 +79,7 b' define([' | |||
|
80 | 79 | that.unregister_comm(comm); |
|
81 | 80 | var wrapped_error = new utils.WrappedError("Exception opening new comm", e); |
|
82 | 81 | console.error(wrapped_error); |
|
83 |
return |
|
|
82 | return Promise.reject(wrapped_error); | |
|
84 | 83 | } |
|
85 | 84 | return comm; |
|
86 | 85 | }, utils.reject('Could not open comm', true)); |
@@ -7,8 +7,7 b' define([' | |||
|
7 | 7 | "jquery", |
|
8 | 8 | "base/js/utils", |
|
9 | 9 | "base/js/namespace", |
|
10 | 'rsvp', | |
|
11 | ], function (_, Backbone, $, utils, IPython, rsvp) { | |
|
10 | ], function (_, Backbone, $, utils, IPython) { | |
|
12 | 11 | "use strict"; |
|
13 | 12 | //-------------------------------------------------------------------- |
|
14 | 13 | // WidgetManager class |
@@ -50,7 +49,7 b' define([' | |||
|
50 | 49 | WidgetManager.prototype.display_view = function(msg, model) { |
|
51 | 50 | // Displays a view for a particular model. |
|
52 | 51 | var that = this; |
|
53 |
return new |
|
|
52 | return new Promise(function(resolve, reject) { | |
|
54 | 53 | var cell = that.get_msg_cell(msg.parent_header.msg_id); |
|
55 | 54 | if (cell === null) { |
|
56 | 55 | reject(new Error("Could not determine where the display" + |
@@ -241,7 +240,7 b' define([' | |||
|
241 | 240 | }, function(error) { |
|
242 | 241 | delete that._models[model_id]; |
|
243 | 242 | var wrapped_error = new utils.WrappedError("Couldn't create model", error); |
|
244 |
return |
|
|
243 | return Promise.reject(wrapped_error); | |
|
245 | 244 | }); |
|
246 | 245 | this._models[model_id] = model_promise; |
|
247 | 246 | return model_promise; |
@@ -7,8 +7,7 b' define(["widgets/js/manager",' | |||
|
7 | 7 | "jquery", |
|
8 | 8 | "base/js/utils", |
|
9 | 9 | "base/js/namespace", |
|
10 | "rsvp", | |
|
11 | ], function(widgetmanager, _, Backbone, $, utils, IPython, rsvp){ | |
|
10 | ], function(widgetmanager, _, Backbone, $, utils, IPython){ | |
|
12 | 11 | |
|
13 | 12 | var WidgetModel = Backbone.Model.extend({ |
|
14 | 13 | constructor: function (widget_manager, model_id, comm) { |
@@ -23,7 +22,7 b' define(["widgets/js/manager",' | |||
|
23 | 22 | // An ID unique to this model. |
|
24 | 23 | // comm : Comm instance (optional) |
|
25 | 24 | this.widget_manager = widget_manager; |
|
26 |
this.state_change = |
|
|
25 | this.state_change = Promise.resolve(); | |
|
27 | 26 | this._buffered_state_diff = {}; |
|
28 | 27 | this.pending_msgs = 0; |
|
29 | 28 | this.msg_buffer = null; |
@@ -101,7 +100,7 b' define(["widgets/js/manager",' | |||
|
101 | 100 | } finally { |
|
102 | 101 | that.state_lock = null; |
|
103 | 102 | } |
|
104 |
return |
|
|
103 | return Promise.resolve(); | |
|
105 | 104 | }, utils.reject("Couldn't set model state", true)); |
|
106 | 105 | }, |
|
107 | 106 | |
@@ -262,7 +261,7 b' define(["widgets/js/manager",' | |||
|
262 | 261 | _.each(value, function(sub_value, key) { |
|
263 | 262 | unpacked.push(that._unpack_models(sub_value)); |
|
264 | 263 | }); |
|
265 |
return |
|
|
264 | return Promise.all(unpacked); | |
|
266 | 265 | } else if (value instanceof Object) { |
|
267 | 266 | unpacked = {}; |
|
268 | 267 | _.each(value, function(sub_value, key) { |
@@ -273,7 +272,7 b' define(["widgets/js/manager",' | |||
|
273 | 272 | // get_model returns a promise already |
|
274 | 273 | return this.widget_manager.get_model(value.slice(10, value.length)); |
|
275 | 274 | } else { |
|
276 |
return |
|
|
275 | return Promise.resolve(value); | |
|
277 | 276 | } |
|
278 | 277 | }, |
|
279 | 278 |
General Comments 0
You need to be logged in to leave comments.
Login now