以下の内容はhttps://anton0825.hatenablog.com/entry/2015/08/11/000000より取得しました。


promiseをthenの中からrejectする

thenの中でpromiseチェーンをrejectしたい場合、rejectedなpromiseをreturnすればよい。例は以下。

api.ajaxCall(param).then((result: ResponseJSON<A>) => {
  return $.Deferred().reject().promise();
});

thenからpromiseをreturnすると、returnしたpromiseの実行が終わってから次のthenに進む。 例えば、以下のコードではコメントの#1,#2,#3の順で実行される。

api.ajaxCall(param1).then((result: ResponseJSON<A>) => {
  // #1
  return api.ajaxCall(param2).then((result: ResponseJSON<A>) => {
    // #2
  });
}).then(() => {
  // #3
});

参考:




以上の内容はhttps://anton0825.hatenablog.com/entry/2015/08/11/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14