Skip to content

Instantly share code, notes, and snippets.

@davidbiehl
Created October 16, 2014 22:31
Show Gist options
  • Save davidbiehl/3d29bfd5d30e5bf3301c to your computer and use it in GitHub Desktop.
Save davidbiehl/3d29bfd5d30e5bf3301c to your computer and use it in GitHub Desktop.
Mutant Collection
class MutantCollection extends Backbone.Collection
constructor: (collection, mutator, options = {})->
super(collection.map(mutator), options)
@listenTo collection, 'reset', ->
@reset collection.map(mutator)
@listenTo collection, 'add', (model)->
@add mutator(model)
@listenTo collection, 'remove', (model)->
@remove mutator(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment