uangsl
3/12/2017 - 6:12 AM

javascript Promise

javascript Promise

new Promise(function(resolve, reject){
  setTimeout(function(){
  	console.log("resolve", 1);
    resolve("result");
  }, 2000);
}).then(function(v){
	return new Promise(function(resolve, reject) {
      console.log("then", 2);
      setTimeout(function(){
        console.log("then", 3);
        //resolve(v);
      }, 2000);
  });
}).then(function(v){
  console.log("then then", 4);
  console.log("then then", v);
});