ractivejs/ractive-adaptors-backbone — pull request #22 by anton-ryzhov (2014-10-02 08:15:30+00:00)
Title: Debounce change events to prevent `event.on`/`event.off` storm on batch change

When `ractive` displays `backbone`'s collection, it monitors events on collection itself and its models.
When we do `collection.fetch()` it triggers `set`/`reset`, on collection and `add` on **each** model.
`Ractive` does **huge** work on `add`, resetting event handlers, updates parent keypathes, etc.

As result — loading and displaying 20 models took ~**1500** calling of `changeHandler` and 1.2 seconds on my machine (according to `console.time`/`timeEnd`).

I've added `underscore.debounce` (as far we already depend on `underscore` through `backbone`) to decrease change event triggering times.

This will slowdown rerender after atomic update for `debounceInterval` (50 msec), but add huge speedup in batch changes. In my case, 20 models — 30 calls of `changeHandler` and 30 msec total time. **40 times** faster!

Actually I've got the same result with `debounceInterval=10`, but I think 50 is good balance between processing in slow browser and responsiveness in fast one.