Repository navigation
fix(maui): deliver Deactivated to the view model a parked view was activated with - #55
Open
michaelstonis wants to merge 2 commits into
Open
michaelstonis wants to merge 2 commits into
michaelstonis wants to merge 2 commits into
Conversation
…cument the option Passing 0 to a list that had never opted in created a watcher and a PropertyChanged subscription for a list that keeps nothing. Adds the README section for the option, tests that a list which has not opted in is not watched and that opting in after rows are bound takes effect, and puts every MAUI test class through UseStellarComponents so results cannot depend on which class initialises ReactiveUI first. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tivated with When a kept recycled view's view model was replaced while it was parked, Deactivated went to the replacement, which had never been activated, and the original got only Unregister. ReactiveUI deactivates the old view model before activating the new one; this follows that order. ViewManager gains a protected OnLifecycle(TViewModel?, LifecycleEvent) so a derived manager can address a view model the view no longer holds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The public lifecycle documentation contradicts the new view-model replacement behavior.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Corrects lifecycle delivery when a parked MAUI row’s view model is replaced.
Changes:
- Deactivates the originally activated view model.
- Adds recycling lifecycle regression tests.
- Includes stacked recycling, test setup, and documentation updates.
| File | Description |
|---|---|
Stellar/ViewManager.cs |
Adds targeted lifecycle dispatch. |
Stellar.Maui/MauiViewManager.cs |
Corrects parked-row deactivation. |
Stellar.Maui/Extensions/ItemsViewExtensions.cs |
Avoids watchers for zero limits. |
Stellar.Maui.UnitTests/StellarTestBase.cs |
Documents shared ReactiveUI initialization. |
Stellar.Maui.UnitTests/MauiTestBase.cs |
Uses shared test initialization. |
Stellar.Maui.UnitTests/ItemsViewRecyclingTests.cs |
Adds recycling regression coverage. |
README.md |
Documents retained recycled rows. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+530
to
+533
| A kept row does **not** run `Bind`, `Initialized`, `Activated` or `Deactivated` again when it | ||
| is given its next item; it only receives `Detached` and `Attached`, and its view model's | ||
| item changes. Opt in only for rows that take everything they show from bindings to the view | ||
| model. A row that reads its item imperatively inside `Bind` would show the previous item. |
| } | ||
|
|
||
| // The view was given another view model while it was recycled. The one it was | ||
| // parked with is the one that was activated, so Deactivated is its to receive. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Stacked on #54 (its commit shows here until it merges).
Why
With the opt-in recycled-row feature, a kept row can have its view model replaced while it is parked. When it then returned (or the list left the window),
Deactivatedwent to the replacement, which had never beenActivated, and the original, which had, got onlyUnregister(). Verified by a characterisation test on the base: original[Initialized, Activated, Attached, Detached], replacement[Deactivated, Initialized, Activated, Attached].ReactiveUI's own
HandleViewModelActivationdeactivates the old view model before activating the new one; this follows that order. Details and sources are inreview-follow-ups-research-2026-10-05.mdon #56's branch.What
ViewManager<TViewModel>(core) gainsprotected void OnLifecycle(TViewModel? viewModel, LifecycleEvent); the publicOnLifecycle(view, …)forwards to it. No state, no virtual call, non-breaking.MauiViewManager.DeactivateParkedraisesDeactivatedto the parked view model, then unregisters the bindings, unregisters the original, and disposes the view. The replacement seesInitialized, Activated, Attachedonly. The view-levelLifecycleEventsstream still emitsDeactivatedonce.Only consumer view models implementing
ILifecycleEventAwareon an opted-in list were affected.Verification
dotnet build Stellar.slnf -c Release: 0 errors;Stellar.UnitTests259/259;Stellar.Maui.UnitTests202/202 onnet10.0.🤖 Generated with Claude Code