mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +01:00
Use native promises (fixes microsoft/monaco-editor#1766)
This commit is contained in:
parent
2ed113477e
commit
71bbf3f7a5
1 changed files with 3 additions and 5 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
require(['vs/editor/editor.main'], function() {
|
require(['vs/editor/editor.main'], function() {
|
||||||
var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
|
var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
|
||||||
|
|
||||||
monaco.Promise.join([xhr('original.txt'), xhr('modified.txt')]).then(function(r) {
|
Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function(r) {
|
||||||
var originalTxt = r[0].responseText;
|
var originalTxt = r[0].responseText;
|
||||||
var modifiedTxt = r[1].responseText;
|
var modifiedTxt = r[1].responseText;
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
<script>
|
<script>
|
||||||
function xhr(url) {
|
function xhr(url) {
|
||||||
var req = null;
|
var req = null;
|
||||||
return new monaco.Promise(function(c,e,p) {
|
return new Promise(function(c,e) {
|
||||||
req = new XMLHttpRequest();
|
req = new XMLHttpRequest();
|
||||||
req.onreadystatechange = function () {
|
req.onreadystatechange = function () {
|
||||||
if (req._canceled) { return; }
|
if (req._canceled) { return; }
|
||||||
|
|
@ -42,8 +42,6 @@
|
||||||
e(req);
|
e(req);
|
||||||
}
|
}
|
||||||
req.onreadystatechange = function () { };
|
req.onreadystatechange = function () { };
|
||||||
} else {
|
|
||||||
p(req);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue