You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a suggestion for a possibly handy shorthand of @@method for the equivalent of fn.bind(this) (or in CoffeeScript parlance __bind).
This is just a bit of syntactic sugar where one has a class with a number of handlers e.g. for illustration:
classHandlerconstructor: (node) ->$(node)
.on('click', @@on_click)
.on("mouseover", @@on_mouserover)
# versus
.on('click', @on_click.bind(@)) # ES5, or
.on('click', _.bind(@on_click, @) # lodash/underscoreon_click:->#...on_mouseover:-># ...
This is not to rule out alternative syntax options, but it struck me that @@ was a. unused, b. somewhat expressive of the intention, and c. easy to remember.
Cheers.
The text was updated successfully, but these errors were encountered:
Just a suggestion for a possibly handy shorthand of
@@method
for the equivalent offn.bind(this)
(or in CoffeeScript parlance__bind
).This is just a bit of syntactic sugar where one has a class with a number of handlers e.g. for illustration:
This is not to rule out alternative syntax options, but it struck me that
@@
was a. unused, b. somewhat expressive of the intention, and c. easy to remember.Cheers.
The text was updated successfully, but these errors were encountered: