content/hifi-public/scripts/libraries/promiseExample.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

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);
});