Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var thinkForXMin = function(time, out){
- return new Promise(
- function(t, c){
- setTimeout(function(){
- t(out);
- }, time);
- }
- );
- };
- var checkLot = function(t){
- setTimeout(function(){
- //c("I LOST");
- t( Promise.reject("I lost big time. :-(") );
- }, 1000);
- };
- var aaron = function(result){
- console.log( "Aaron Message: " + result );
- return "Aaron going back to work.";
- };
- var larry = function(result){
- console.log( "Larry Message: " + result );
- return thinkForXMin(1000, "I only want to buy if you lose.");
- };
- var whatWouldHeDo = function(result){
- console.log( "He did this. Message: " + result );
- };
- var catchEverything = function(result){
- console.log( "1) WTF is this? " + result );
- return "1) Stop playing the lottery.";
- };
- var catchEverything2 = function(result){
- console.log( "2) WTF is this? " + result );
- return "2) Stop playing the lottery.";
- };
- var p = new Promise(checkLot);
- p.catch(larry);
- p.then(aaronm).then(whatWouldHeDo).catch(catchEverything);
- p.catch(catchEverything2).then(larry).then(whatWouldHeDo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement