mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 09:20:10 +01:00
debt - more promise cleanup
This commit is contained in:
parent
a404c91e22
commit
70e48eeb52
5 changed files with 386 additions and 392 deletions
|
|
@ -60,7 +60,7 @@ monaco.editor.create(document.getElementById("container"), {
|
|||
|
||||
function xhr(url) {
|
||||
var req = null;
|
||||
return new monaco.Promise(function(c,e,p) {
|
||||
return new Promise(function(c,e) {
|
||||
req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req._canceled) { return; }
|
||||
|
|
@ -72,8 +72,6 @@ function xhr(url) {
|
|||
e(req);
|
||||
}
|
||||
req.onreadystatechange = function () { };
|
||||
} else {
|
||||
p(req);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ define(['./samples-all.generated'], function(ALL_SAMPLES) {
|
|||
name: 'sample - ' + modeId,
|
||||
mimeType: modeId,
|
||||
loadText: function () {
|
||||
return monaco.Promise.as(XHR_SAMPLES['sample.' + modeId + '.txt']);
|
||||
return Promise.resolve(XHR_SAMPLES['sample.' + modeId + '.txt']);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -28,7 +28,7 @@ define(['./samples-all.generated'], function(ALL_SAMPLES) {
|
|||
name: name,
|
||||
mimeType: mimeType,
|
||||
loadText: function () {
|
||||
return monaco.Promise.as(XHR_SAMPLES[modelUrl]).then(textModifier);
|
||||
return Promise.resolve(XHR_SAMPLES[modelUrl]).then(textModifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ define(['./samples-all.generated'], function(ALL_SAMPLES) {
|
|||
name: name,
|
||||
mimeType: mimeType,
|
||||
loadText: function () {
|
||||
return monaco.Promise.as(modelText);
|
||||
return Promise.resolve(modelText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
}
|
||||
|
||||
require(['./samples'], function(SAMPLES) {
|
||||
monaco.Promise.join(
|
||||
Promise.all(
|
||||
SAMPLES.map(resolveSample)
|
||||
).then(function(samples) {
|
||||
renderSamples(samples);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ monaco.editor.create(document.getElementById("container"), {
|
|||
|
||||
function xhr(url) {
|
||||
var req = null;
|
||||
return new monaco.Promise(function(c,e,p) {
|
||||
return new Promise(function (c, e) {
|
||||
req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req._canceled) { return; }
|
||||
|
|
@ -34,8 +34,6 @@ function xhr(url) {
|
|||
e(req);
|
||||
}
|
||||
req.onreadystatechange = function () { };
|
||||
} else {
|
||||
p(req);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ function load() {
|
|||
var js = xhr(samplePath + '/sample.js').then(function (response) { return response.responseText });
|
||||
var css = xhr(samplePath + '/sample.css').then(function (response) { return response.responseText });
|
||||
var html = xhr(samplePath + '/sample.html').then(function (response) { return response.responseText });
|
||||
monaco.Promise.join([js, css, html]).then(function(_) {
|
||||
Promise.all([js, css, html]).then(function (_) {
|
||||
var js = _[0];
|
||||
var css = _[1];
|
||||
var html = _[2];
|
||||
|
|
@ -350,13 +350,13 @@ var preloaded = {};
|
|||
|
||||
function xhr(url) {
|
||||
if (preloaded[url]) {
|
||||
return monaco.Promise.as({
|
||||
return Promise.resolve({
|
||||
responseText: preloaded[url]
|
||||
});
|
||||
}
|
||||
|
||||
var req = null;
|
||||
return new monaco.Promise(function(c,e,p) {
|
||||
return new Promise(function (c, e) {
|
||||
req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req._canceled) { return; }
|
||||
|
|
@ -368,8 +368,6 @@ function xhr(url) {
|
|||
e(req);
|
||||
}
|
||||
req.onreadystatechange = function () { };
|
||||
} else {
|
||||
p(req);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue