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

Please add a clearChange() to cortex #89

Closed
serle opened this issue Jul 12, 2015 · 1 comment
Closed

Please add a clearChange() to cortex #89

serle opened this issue Jul 12, 2015 · 1 comment

Comments

@serle
Copy link

serle commented Jul 12, 2015

Could I suggest that you add a clearChanges() function to Cortex. This would have the side effect of making a ssubsequent call to didChange() function return false again (unless there was infact another cortex change.

The use case would be

onUpdate(updatedData) {
React.render({model: updatedData}) //it can fully utilise the didChange() for render optimisation

  updatedData.clearChanges() //this ensures that subsequent React re-rendering base on prop or  state outside of cortex control can be optimised alongside a properly working cortex.didChange() call which now returns false when it did not change since the last clearChanges()  

}

@mquan
Copy link
Owner

mquan commented Jul 12, 2015

This is a good idea, but one danger with something like this is you have to guarantee it's only called at the very end of the render loop. I don't think you can simply call it in onUpdate callback because there's no way to be sure react finishes rendering all its components. I'd rather make this an option and hook into react componentDidUpdate to prevent users from improperly calling it.

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

No branches or pull requests

2 participants