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

Dispose properly ViewNode and Component when Widget is removed from tree #1066

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

TimLariviere
Copy link
Member

@TimLariviere TimLariviere commented Jan 30, 2024

New dependency tree:

graph TD;
    Control-->ViewNode
    ViewNode-->Events[Event handlers]
    ViewNode-->Component
    Component-->ComponentContext
    ComponentContext-->Runner
    Runner-->Subscriptions
Loading

When Fabulous detects a widget is removed from the view tree, it will dispose the associated ViewNode, which in turn will dispose the whole dependency tree.

We need to rely on ViewNode.Dispose() because frameworks like Maui doesn't provide any event telling us when a control is removed from the UI tree. The Unloaded event of Maui for example is called as soon as the control is no longer visible (eg we navigated to another page, but the previous page is still supposed to be alive)

@TimLariviere TimLariviere merged commit 0d5f4c2 into main Jan 30, 2024
1 check passed
@TimLariviere TimLariviere deleted the disposable-component branch January 30, 2024 17:31
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

Successfully merging this pull request may close these issues.

None yet

2 participants