reactiveui / reactiveui/Sextant
feature: Provide an initialization hook for when the VM/view is going to be added to the stack/pushed
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 161
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
It's related to usability and improving of lifecycle.
WhenActivatedhappens too late on the VM/View cycle to start performing operations, such as loading data at VM level, setting up bindings in the view. The order of execution can be seen here:
ViewModel Constructor
View Constructor: 691 milliseconds
View OnAppearing: 1172 milliseconds
ViewModel WhenActivated: 1180 milliseconds
View WhenActivated: 1192 milliseconds
- Due to the late
WhenActivatedexecution as stated above, for my case I exposed aViewModelDidBind, which is a simplethis.WhenAnyValue(v => v.ViewModel)exposed on my view base, so there I can start invoking commands, earlier. It does execute only once, when the viewmodel is set on that view instance, that differs from theOnAppearingand theWhenActivatedcause both will be executed every time the view/viewmodel gets displayed. TheViewModelDidBindworks for my purpose of starting things earlier in the flow (gets executed right after the view constructor) as follows:
View ViewModelDidBind: 705 milliseconds
Describe the solution you'd like
For performing operations/bindings I'd say I could start them right away when the view/viewmodel is added to the stack, that is a good earlier moment to setup things.
Describe alternatives you've considered
Describe suggestions on how to achieve the feature
What I can think right away is to expose a (potentially new) interface on Sextant and then to call it accordingly when adding that into the stack, and then let the view/viewmodel that's interested on it to implement that interface that would have that new "hook". Knowing it's being "initialized" it could perform the needed operations accordingly.
Additional context
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Sextant navigation path where a view or view model is added to the stack, then compare its existing WhenActivated and OnAppearing lifecycle behavior. Define the initialization hook at the stack-insertion point and verify that it runs before display while preserving the existing repeated lifecycle behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop-dev, mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100