Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batching of external events #956

Closed
syranide opened this issue Jan 23, 2014 · 2 comments
Closed

Batching of external events #956

syranide opened this issue Jan 23, 2014 · 2 comments

Comments

@syranide
Copy link
Contributor

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

@plievone
Copy link
Contributor

See also #906

@syranide
Copy link
Contributor Author

Thanks @plievone, so this is a duplicate of #906, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants