[Javascript]コールバックモードvs基本モード
1.コールバックモード
var callBack = function(text, done){
console.log('callBackkFunc', text);
done(text + ' done');
}
callBack('test Text', function(res){
console.log('Success', res);
})
2.インフラストラクチャ・モード(Promise Pattern)
var callBack = function(text){
return new Promise(function(resolve, reject) {
console.log('callBackkFunc', text);
resolve(text + ' done');
})
}
callBack('test Text').then(function(res){
console.log('Success', res);
}).catch(function(error){
console.log('error', error);
})
関連項目:https://geundung.dev/53
Reference
この問題について([Javascript]コールバックモードvs基本モード), 我々は、より多くの情報をここで見つけました https://velog.io/@pptrolldev/Javascript-콜백Call-Back-패턴-vs-프라미스Promise-패턴テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol