Jonathan Frederic 11 years ago committed by Jonathan Frederic
parent 8c149c9112
commit bed3a4cfda

@ -5,8 +5,7 @@ define([
'base/js/namespace',
'jquery',
'codemirror/lib/codemirror',
'rsvp',
], function(IPython, $, CodeMirror, rsvp){
], function(IPython, $, CodeMirror){
"use strict";
IPython.load_extensions = function () {
@ -641,7 +640,7 @@ define([
// Tries to load a class from a module using require.js, if a module
// is specified, otherwise tries to load a class from the global
// registry, if the global registry is provided.
return new rsvp.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
// Try loading the view module using require.js
if (module_name) {
@ -664,13 +663,13 @@ define([
var resolve_dict = function(d) {
// Resolve a promiseful dictionary.
// Returns a single rsvp.Promise.
// Returns a single Promise.
var keys = Object.keys(d);
var values = [];
keys.forEach(function(key) {
values.push(d[key]);
});
return rsvp.Promise.all(values).then(function(v) {
return Promise.all(values).then(function(v) {
d = {};
for(var i=0; i<keys.length; i++) {
d[keys[i]] = v[i];
@ -707,15 +706,15 @@ define([
WrappedError.prototype = Object.create(Error.prototype, {});
var reject = function(message, log) {
// Creates a wrappable rsvp.Promise rejection function.
// Creates a wrappable Promise rejection function.
//
// Creates a function that returns a rsvp.Promise.reject with a new WrappedError
// Creates a function that returns a Promise.reject with a new WrappedError
// that has the provided message and wraps the original error that
// caused the promise to reject.
return function(error) {
var wrapped_error = new WrappedError(message, error);
if (log) console.error(wrapped_error);
return rsvp.Promise.reject(wrapped_error);
return Promise.reject(wrapped_error);
};
};

@ -49,6 +49,7 @@ require([
custom
) {
"use strict";
console.log(promise);
// compat with old IPython, remove for IPython > 3.0
window.CodeMirror = CodeMirror;

@ -5,8 +5,7 @@ define([
'base/js/namespace',
'jquery',
'base/js/utils',
'rsvp',
], function(IPython, $, utils, rsvp) {
], function(IPython, $, utils) {
"use strict";
//-----------------------------------------------------------------------
@ -80,7 +79,7 @@ define([
that.unregister_comm(comm);
var wrapped_error = new utils.WrappedError("Exception opening new comm", e);
console.error(wrapped_error);
return rsvp.Promise.reject(wrapped_error);
return Promise.reject(wrapped_error);
}
return comm;
}, utils.reject('Could not open comm', true));

@ -7,8 +7,7 @@ define([
"jquery",
"base/js/utils",
"base/js/namespace",
'rsvp',
], function (_, Backbone, $, utils, IPython, rsvp) {
], function (_, Backbone, $, utils, IPython) {
"use strict";
//--------------------------------------------------------------------
// WidgetManager class
@ -50,7 +49,7 @@ define([
WidgetManager.prototype.display_view = function(msg, model) {
// Displays a view for a particular model.
var that = this;
return new rsvp.Promise(function(resolve, reject) {
return new Promise(function(resolve, reject) {
var cell = that.get_msg_cell(msg.parent_header.msg_id);
if (cell === null) {
reject(new Error("Could not determine where the display" +
@ -241,7 +240,7 @@ define([
}, function(error) {
delete that._models[model_id];
var wrapped_error = new utils.WrappedError("Couldn't create model", error);
return rsvp.Promise.reject(wrapped_error);
return Promise.reject(wrapped_error);
});
this._models[model_id] = model_promise;
return model_promise;

@ -7,8 +7,7 @@ define(["widgets/js/manager",
"jquery",
"base/js/utils",
"base/js/namespace",
"rsvp",
], function(widgetmanager, _, Backbone, $, utils, IPython, rsvp){
], function(widgetmanager, _, Backbone, $, utils, IPython){
var WidgetModel = Backbone.Model.extend({
constructor: function (widget_manager, model_id, comm) {
@ -23,7 +22,7 @@ define(["widgets/js/manager",
// An ID unique to this model.
// comm : Comm instance (optional)
this.widget_manager = widget_manager;
this.state_change = rsvp.Promise.resolve();
this.state_change = Promise.resolve();
this._buffered_state_diff = {};
this.pending_msgs = 0;
this.msg_buffer = null;
@ -101,7 +100,7 @@ define(["widgets/js/manager",
} finally {
that.state_lock = null;
}
return rsvp.Promise.resolve();
return Promise.resolve();
}, utils.reject("Couldn't set model state", true));
},
@ -262,7 +261,7 @@ define(["widgets/js/manager",
_.each(value, function(sub_value, key) {
unpacked.push(that._unpack_models(sub_value));
});
return rsvp.Promise.all(unpacked);
return Promise.all(unpacked);
} else if (value instanceof Object) {
unpacked = {};
_.each(value, function(sub_value, key) {
@ -273,7 +272,7 @@ define(["widgets/js/manager",
// get_model returns a promise already
return this.widget_manager.get_model(value.slice(10, value.length));
} else {
return rsvp.Promise.resolve(value);
return Promise.resolve(value);
}
},

@ -31,7 +31,6 @@
codemirror: 'components/codemirror',
termjs: "components/term.js/src/term",
contents: '{{ contents_js_source }}',
rsvp: "components/rsvp/rsvp",
},
shim: {
underscore: {

Loading…
Cancel
Save