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

Redraw being sometimes synchronous, it would benefit from a lock mechanism #1693

Closed
FremyCompany opened this issue Mar 8, 2017 · 2 comments
Labels
Type: Enhancement For any feature request or suggestion that isn't a bug fix

Comments

@FremyCompany
Copy link

Here is a problem I have:

  • I have some property whose value can be updated; when it is, a redraw is necessary, so the setter will call m.redraw()
  • Sometimes, updating this property is just part of a longer chain of updates
  • Most of the times, this works just fine, but sometimes the optimization where redraw is synchronous kicks in while the state is not consistent yet, resulting if a flash of incorrect content.
model.property1 = value1; // if redraw() is synchronous, the second update will be missed for a frame
model.property2 = value2; // now redraw() will be delayed for sure so improper content displays

To solve this problem for my project I created my own synchronization helpers (I don't call m.redraw but some helper that will not trigger an actual redraw if an operation is in progress, and will instead wait for this operation to complete before triggering a redraw to make sure the state is never inconsistent).

I think this should be part of the built-in library, the current redraw mechanics are kinda annoying, especially if you have to work with promises obtained from the DOM APIs.

Any opinion?

@pygy
Copy link
Member

pygy commented Mar 8, 2017

There's a WIP PR to make m.redraw always async #1592 I need to fix the merge conflicts in the tests, though.

@dead-claudia dead-claudia added the Type: Enhancement For any feature request or suggestion that isn't a bug fix label Jun 15, 2017
@dead-claudia
Copy link
Member

v2's m.redraw has been split into separate sync/async versions. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement For any feature request or suggestion that isn't a bug fix
Projects
None yet
Development

No branches or pull requests

3 participants