-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: activate iOS views synchronously #1540
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
Conversation
Fixes current (undesirable) behaviour where bindings are evaluated after views become visible. After this change, bindings are evaluated prior to views being shown.
|
@tgjones, It will cover your contributions to all .NET Foundation-managed open source projects. |
|
@tgjones, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
|
The AppVeyor build failure looks unrelated to my changes, but please let me know if I need to fix something. |
|
I actually ran into this (again) today, so I'm all for it! I've also noticed breaking of AutoLayout in cells because of the unnecessary scheduling. |
|
Great - thanks @tgjones! And yeah, the build error is definitely unrelated :/ |
|
Build fixed in #1542, just waiting for merge before I can merge this. |
|
Changes Unknown when pulling 9196f30 on tgjones:cocoa-activation into ** on reactiveui:develop**. |
|
Great, thanks for merging! |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
This is either a bug fix or enhancement, depending on how you look at it. It applies the equivalent activation fix for
UIViewsubclasses, that #1182 already did forUIViewControllersubclasses.#1182 changed
UIViewControllersubclasses to useViewWillAppearinstead ofViewDidAppearfor activation, such that activation occurs before the view becomes visible.This PR does the equivalent thing for
UIViewsubclasses.What is the current behavior? (You can also link to an open issue here)
UIViewsubclasses (correctly) overrideWillMoveToSuperview, which is called before the view becomes visible. However, within those overrides, they schedule an async callback on the UI thread like this:Because
Scheduleschedules an async callback on the UI thread, the callback may (and in my testing, will) be called after the view becomes visible. This means that there's a visible flicker where you first see uninitialized views, and then they are populated with data.What is the new behavior (if this is a feature change)?
The activation callbacks are now called synchronously from
UIViewsubclasses, such that activation occurs before the view becomes visible. Instead of the code above, theWillMoveToSuperviewoverrides become simpler:This matches the existing behaviour for ReactiveCollectionReusableView and ReactiveCollectionView, which already called the activation callback synchronously.
What might this PR break?
If anybody relies on the current behaviour of activation occurring after views become visible, this would be a breaking change. But that was almost certainly undesirable behaviour in the first place.
Please check if the PR fulfills these requirements
Other information: