I am not sure if that would work. I would recommend:
var p = new Promise(function (resolve, reject) {
$.getJSON('api/values', null)
.then(resolve, reject);
});
preferably you could create an adaptorfunction like:
var toPromise = function ($promise) {
return new Promise(function (resolve, reject) {
$promise.then(resolve, reject);
});
});
var p = toPromise($.getJSON('api/values', null));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…