Created
October 16, 2014 22:31
-
-
Save davidbiehl/3d29bfd5d30e5bf3301c to your computer and use it in GitHub Desktop.
Mutant Collection
This file contains 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
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