mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-05 21:02:26 +02:00
18 lines
No EOL
441 B
JavaScript
18 lines
No EOL
441 B
JavaScript
Script.include('promise.js');
|
|
var Promise = loadPromise();
|
|
var prom = new Promise(function(resolve, reject) {
|
|
print('making a promise')
|
|
// do a thing, possibly async, then…
|
|
var thing = true;
|
|
if (thing) {
|
|
resolve("Stuff worked!");
|
|
} else {
|
|
print('ERROR')
|
|
reject(new Error("It broke"));
|
|
}
|
|
});
|
|
|
|
// Do something when async done
|
|
prom.then(function(result) {
|
|
print('result ' + result);
|
|
}); |