Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Views and view trees are destroyed when removed from the view tree.
What is the new behavior?
Views can be marked as
reusable
and will not be destroyed when removed from view tree. Removing these nodes require the developer to do:For implementation details on how frameworks should deal with it, see my work in
nativescript-angular
: https://github.com/edusperoni/nativescript-angular/tree/reusable-viewsImplements #7469.
Rewrite of #8184
To be defined:
What happens when a reusable view with children gets removed? The current implementation does not call _tearDownUI on children, but we should still suspendNativeUpdates down the chain (
this._suspendNativeUpdates(SuspendType.UISetup);
).Maybe we should we create a new SuspendType (Detached)? Maybe this isn't even needed as the view should be unloaded by
_removeViewCore
which eventually callsthis._suspendNativeUpdates(SuspendType.Loaded);
on all children.Possible refactoring needed (not directly related to this PR)
The current logic of
_resumeNativeUpdates
will callinitNativeView
. In most places I checked,initNativeView
creates delegates that are only removed indisposeNativeView
. This behavior is probably already an issue on loading/unloading views (like navigation) because ofthis._resumeNativeUpdates(SuspendType.Loaded);
, meaninginitNativeView
is called multiple times during the application lifecycle, but the delegates are only cleaned up once.During my tests with WebView, calling
initNativeView
did not result in a performance impact