Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: reusable views #9163

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

Merged
merged 1 commit into from
Jan 29, 2021
Merged

feat: reusable views #9163

merged 1 commit into from
Jan 29, 2021

Conversation

edusperoni
Copy link
Contributor

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:

view.destroyNode();
// which calls
view.reusable = false;
view._tearDownUI();

For implementation details on how frameworks should deal with it, see my work in nativescript-angular: https://github.com/edusperoni/nativescript-angular/tree/reusable-views

Implements #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 calls this._suspendNativeUpdates(SuspendType.Loaded); on all children.

Possible refactoring needed (not directly related to this PR)

The current logic of _resumeNativeUpdates will call initNativeView. In most places I checked, initNativeView creates delegates that are only removed in disposeNativeView. This behavior is probably already an issue on loading/unloading views (like navigation) because of this._resumeNativeUpdates(SuspendType.Loaded);, meaning initNativeView 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

@cla-bot cla-bot bot added the cla: yes label Jan 21, 2021
@rigor789 rigor789 added this to the 8.0 milestone Jan 26, 2021
@NathanWalker NathanWalker merged commit db09efe into release/8.0.0 Jan 29, 2021
@NathanWalker NathanWalker deleted the edusperoni/reusable-views branch January 29, 2021 19:13
NathanWalker pushed a commit that referenced this pull request Feb 12, 2021
NathanWalker pushed a commit that referenced this pull request Feb 27, 2021
NathanWalker pushed a commit that referenced this pull request Feb 27, 2021
NathanWalker pushed a commit that referenced this pull request Mar 3, 2021
NathanWalker pushed a commit that referenced this pull request Mar 5, 2021
NathanWalker pushed a commit that referenced this pull request Apr 2, 2021
NathanWalker pushed a commit that referenced this pull request Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants