Skip to content

Too many calls to forceUpdate #9

@duhseekoh

Description

@duhseekoh

I've recently used a similar mixin for React. What I've seen so far with using it is that N number additions to a collection triggers forceUpdate N number times.

I changed:

model.on('add remove reset sort', function () { this.forceUpdate(); }, this);

to this (assuming inclusion of underscore or lo-dash):

this._throttledForceUpdate = _.throttle(this.forceUpdate.bind(this, null),  1000);
model.on('add remove reset sort', this._throttledForceUpdate, this);

At most, force update will be called once a second here. Interested in your thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions