0

When I call a function that returns a Promise do I have to use .then() on the promise.

ex. somefunc() returns a promise. Can I just do somefunc(); or do I have to do

 somefunc().then( 
   function(){
   }, 
   function(){
   })

Similarly if I do use .then() do I have to specify both the resolve and reject functions or can I ignore the reject. ex.

 somefunc().then( 
   function(){
   })

My concerns are possible memory etc. leaks.

nevf
  • 4,596
  • 6
  • 31
  • 32
  • Calling `.then()` should have no effect on the process. A Promise represents a result, not the process itself. As it happens, I was just watching the talk [Async Frontiers in JavaScript - Domenic Denicola](https://vimeo.com/132786072) which has a very interesting discussion of related design decisions. – Jeremy Mar 07 '16 at 22:09
  • 2
    You don't have to do anything, but if you want the result of the resolved promise, you have to chain on `then()`, which doesn't have a resolve and reject function, just a callback with the returned data as an argument, the error handler would be `catch()` ! – adeneo Mar 07 '16 at 22:10

0 Answers0