Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import js.Promise;
- class Main {
- static function main() {
- var p1 = new Promise(function(resolve, reject) {
- resolve("YES");
- });
- p1.then(function(v) trace(v), function(e) trace('NOOO!! $e'));
- var p2 = new Promise(function(resolve, reject) {
- reject("BAD");
- });
- p2.then(function(v) trace(v), function(e) trace('NOOO!! $e'));
- Promise.all([p1,p2])
- .then(function(_) {
- trace(_);
- })
- .catchError(function(e) {
- trace('Not again $e');
- });
- Promise.race([p1,p2])
- .then(function(r) {
- trace('Good, $r');
- })
- .catchError(function(e) {
- trace('Not again $e');
- });
- Promise.all([p1,p2])
- .then(function(_) return 1, function(_) return 2)
- .then(function(n : Int) trace(n));
- Promise.all([p1,p2])
- .then(function(_) return Promise.respolve(11), function(_) return Promise.reject(2))
- .then(function(n : Int) trace(n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement