Skip to content

Instantly share code, notes, and snippets.

@cemeng
Created September 27, 2012 05:35
Show Gist options
  • Save cemeng/3792335 to your computer and use it in GitHub Desktop.
Save cemeng/3792335 to your computer and use it in GitHub Desktop.
thin vs fat arrow in CoffeeScript
@http.put(@saveURL, @toServerFormat())
  .success (data) ->
    @loadJobInvoiceItems data.job_invoice.items

JobInvoice.prototype.save = function(doNotifyOfSave) {
  return this.http.put(this.saveURL, this.toServerFormat()).success(function(data) {
    this.loadJobInvoiceItems(data.job_invoice.items);
    if (doNotifyOfSave && typeof notifyOfSave === "function") {
      return notifyOfSave(this.job.id);
    }
  });
};

@http.put(@saveURL, @toServerFormat())
  .success (data) =>
    @loadJobInvoiceItems data.job_invoice.items

JobInvoice.prototype.save = function(doNotifyOfSave) {
  var _this = this;
  return this.http.put(this.saveURL, this.toServerFormat()).success(function(data) {
    _this.loadJobInvoiceItems(data.job_invoice.items);
    if (doNotifyOfSave && typeof notifyOfSave === "function") {
      return notifyOfSave(_this.job.id);
    }
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment