emberjs/data — pull request #2358 by slindberg (2014-10-07 23:17:36+00:00)
Title: Yield in pushMany: proof of concept

Pushing a large number of records into the store can be a very expensive operation. It gets even more expensive the more relations records have to each other. This can then result in the page being unresponsive for an extended period of time, most importantly blocking animations.

This is an experiment to explore solutions to extended blocking. Unfortunately it requires changing the behavior of `store#pushMany` to be asynchronous (something that has surprisingly little impact on ED internals). `pushMany` now looks for `DS.yieldFn` and calls it between each individual call to `store#push`:

```javascript
DS.yieldFn = function(next, index) {
if (index % 3 === 0) {
window.requestAnimationFrame(next);
} else {
next();
}
};
```

This allows the browser to breath every third call to `push`, which is enough for animations to appear smooth. The fixed batch size is a naive solution, but it serves to show what's possible.