Created
May 1, 2015 01:18
-
-
Save foo9/69952aa7b20d2618886c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = new Promise(function(resolve, reject) { | |
if ( /* 何らかの非同期処理 */ ) { | |
resolve(); // 成功 | |
} else { | |
reject(); // 失敗 | |
} | |
}); | |
promise.then(function(result) { | |
// 成功 | |
console.log(result); | |
}, function(error) { | |
// 失敗 | |
console.log(error); | |
}); | |
promise.then(function(result) { | |
// 成功 | |
console.log(result); | |
}).catch(function(error) { | |
// エラーのとき | |
console.log(error); | |
}); | |
// Promise.resolve | |
// Promise.reject | |
// Promise.all | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment