I have a class with a method which gets something from the server. I'm trying to find a way to be able to return "something" from the function that later "becomes" the data which the server responds with. Here's the idea:
@find: (id) ->
  response = THING
  $.ajax
    type: 'GET'
    url: "#{this::url}/#{id}"
    dataType: 'json'
    success: (data) =>
      response.become @init(data)
    error: (xhr, status, error) ->
      response.reject error
  response
The use of this method would look like this:
myBlah = Product.find(1)
I recognize that this is similar to the concept of a promise, which I'm only vaguely familiar with. Is there something I'm missing here?
