Pergunta

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!'
Foi útil?

Solução

I figured it out!

myPromise2: ->
  new Em.RSVP.Promise (resolve, reject) ->
    myPromise()
    resolve()
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top