javascript - Are these 2 Promise writings equivalent? -


from tutorial book following code

  createshoppinglist: (store, shoppinglist) => {     return api.addnewshoppinglist(shoppinglist).then(() => {       store.dispatch('populateshoppinglists')     }, () => {       store.commit(types.add_shopping_list, shoppinglist)     })   } 

notice comma after .then() block

is equivalent chained .then() ?

  createshoppinglist: (store, shoppinglist) => {     return api.addnewshoppinglist(shoppinglist)     .then(() => {       store.dispatch('populateshoppinglists')     })     .then(() => {       store.commit(types.add_shopping_list, shoppinglist)     })   } 

or block inside .then() ? :

return api.addnewshoppinglist(shoppinglist) .then( () => { store.dispatch('populateshoppinglists')},  () => { store.commit(types.add_shopping_list, shoppinglist) } ) 

thanks feedback

no

.then(resolved, rejected) 

is not equal to

.then(resolve) .then(rejected)// :/ 

its rather similar to:

.then(resolved)     .catch(rejected) 

(theres still difference rejection inside of catched now, while upper version uncatched)


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -