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

When swapping out ShellItems clear services #23863

Merged
merged 5 commits into from
Jul 30, 2024
Merged

When swapping out ShellItems clear services #23863

merged 5 commits into from
Jul 30, 2024

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Jul 26, 2024

Description

When the user is switching to a new context on shell and they've loaded the ShellContent via the services out. This will clear out the ContentCache so the service will get retrieved again. This allows the users to specify if they want pages to be transient vs persistent.

Rules for clearing out the cache

  • If the window changes for a shell (this will happen when the user is swapping out the shell)
  • If the user switches to a new ShellItem (new TabBar, new FlyoutItem)
    • The cache will not clear out when switch tabs. It only clears the cache when the app switches to a new "ShellItem" level context
  • If the user sets the ShellItem => ShellSection => ShellContent to not be visible then we'll clear out the cache because the user has indicated that this Page should not longer be part of the active structure

Scenarios where the cache isn't cleared

  • Navigating through bottom tabs
  • Navigation through top tabs
  • if the user hasn't registered the Page itself against the services then we don't clear out the cache. This means for anyone not registering shell services, the behavior won't change.

@PureWeen PureWeen requested a review from a team as a code owner July 26, 2024 20:28
@PureWeen PureWeen marked this pull request as draft July 26, 2024 20:28
@albyrock87
Copy link
Contributor

albyrock87 commented Jul 27, 2024

What about adding the IServiceCollection to itself as a reference so that later with the IServiceProvider we can see how a given type was registered? (Scoped/Transient)

Edit: maybe this comment is not even related to this PR.

@PureWeen PureWeen added this to the 9.0-preview7 milestone Jul 29, 2024
@PureWeen PureWeen marked this pull request as ready for review July 29, 2024 16:22
@PureWeen PureWeen changed the title [WiP] When swapping out ShellItems clear services When swapping out ShellItems clear services Jul 29, 2024
@PureWeen PureWeen merged commit be906a1 into net9.0 Jul 30, 2024
109 of 111 checks passed
@PureWeen PureWeen deleted the shell_lifecycle branch July 30, 2024 23:26
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Aug 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants