有了承諾,我可以鏈中的功能類似於如下承諾行爲:效仿「然後」與RxJS
var p = promiseFactory('1');
p.then(function(data){
/*Do something*/
return promiseFactory('2');
}).then(function(data){
/*Do something else*/
return value;
}).catch(function(err){
/*Here I can catch all exceptions threw in then methods*/
});
我可以渲染RxJS和可觀察到這種行爲如果是的話,怎麼樣?
您可以使用'.flatMap'。其實這取決於你想解決的問題。 –