What is the diference between these two syntax

痞子三分冷 提交于 2019-12-02 11:22:34
Bergi

if the updateUser fails the log will be shown and then second then will not be executed

Yes, because you're branching:

              success: - logSuccessAndResetForm()
               |       - makeNewFormData()
updateUser() --+
  promise      |
              error    - logError()

but when using regular chaining the second chain will be executed

Yes, of course. Your error handler handles the error and the promise is fulfilled with the return value.

              success: - logSuccessAndResetForm()           success: - makeNewFormData()
               |                               \             |
updateUser() --+                                >- promise --+
               |                               /             |
              error    - logError()           ´             error:   (nothing)

See also this answer for prettier control flow diagrams of similar code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!