Skip to content

Instantly share code, notes, and snippets.

@lmartins
Last active August 29, 2015 13:57
Show Gist options
  • Save lmartins/9870916 to your computer and use it in GitHub Desktop.
Save lmartins/9870916 to your computer and use it in GitHub Desktop.
Mixin Pattern in CoffeeScript
# MIXIN PATTERN IN COFFEESCRIPT
mixin = (target, source, methods...) ->
for method in methods
target[method] = source[method].bind(source)
return
# usage:
mixin toggle, toolbar.items[0], 'toggleActiveState'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment