Question

I have a promise here:

myPromise: ->
  return new Em.RSVP.Promise (resolve, reject) ->
    # ...
    resolve 5

How do I write a function to return the promise from myPromise()?

This is what I've tried:

myPromise2: ->
  return myPromise()

myPromise2().then ->
   console.log 'this is never called!'
Était-ce utile?

La solution

I figured it out!

myPromise2: ->
  new Em.RSVP.Promise (resolve, reject) ->
    myPromise()
    resolve()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top