Created
March 21, 2014 20:58
-
-
Save brian-mann/9696358 to your computer and use it in GitHub Desktop.
why doesnt underscore wrap work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Backbone.sync = (method, entity, options = {}) -> | |
| ## THIS WORKS | |
| _.each ["beforeSend", "complete", "error"], (fn) -> | |
| options[fn] or= -> | |
| orig = options[fn] | |
| options[fn] = -> | |
| orig.apply(entity, arguments) | |
| methods[fn].apply(entity, arguments) | |
| ## THIS DOES NOT WORK | |
| _.each ["beforeSend", "complete", "error"], (fn) -> | |
| options[fn] or= -> | |
| _.wrap options[fn], (orig) -> | |
| orig.apply(entity, arguments) | |
| methods[fn].apply(entity, arguments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment