Skip to content

Batching of external events #956

Closed
Closed
@syranide

Description

@syranide

React batches all component updates if they become dirty during an event-callback (events are also batched). However, this is not exposed for use with external events, such as setTimeout, addEventHandler, AJAX-replies, non-React DOM events or any other events, and it seems only natural that it should extend to those too.

I see two obvious solutions:

Export React.batchedUpdates(callback, param)

setTimeout(function() {
  React.batchedUpdates(function() {
    ...
  }.bind(this));
});

setTimeout(React.batchedUpdates.bind(null, function() {
  ...
}.bind(this));

Export a callback factory React.batchedCallback(callback, args...)

setTimeout(React.batchedCallback(function() {
  ...
}.bind(this));

Thoughts?

I'm guessing this belongs with #326

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions