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

Fix activation for nested conductor / screen scenarios #898

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Yinimi
Copy link

@Yinimi Yinimi commented Apr 2, 2024

There have been some discussions and changes related to when OnActivate() is called.
#593 He wanted to use IsInitialized / IsActive to control the visibility of some loading indicator. If the property is set to true before the OnActivate / OnInitialize call it will obviously not be able to use it for determining if the loading has finished.
I can understand the reason for this request but I think a method called OnActivate() should be called after the IsActive is set to true, otherwise Activating or BeforeActivate are better names in my opinion.

Since some devs (like me) want to use OnActivate() to trigger the initializing of the ViewModel there are scenarios where it is problematic if the IsActive is not set yet. I created the ActivateWhileActivateOneLevel() test method to demonstrate it.
To provide such a method @erik-hooper added with #859 a OnActivated() method which is called after the property has been set.
If I use this method with another test ActivatedWhileActivatedOneLevel() The issue is resolved.

I have a more complicated and nested scenario. example Test

  • Outer Conductor
    • some Page
    • Inner Conductor
      • View 1
      • View 2

In my app the inner conductor handles the navigation depending on some configuration.
The outer conductor handles basic stuff and also the display of the user preferences ("some Page").
If the View 1 now wants automatically to continue after the user preferences have been shown (think of auto login was just enabled) then in this nested scenario the View 2 will not be initialized because all this is triggered by the OnActivate() method of the inner conductor.

With this change the behavior should be like before the changes of #593 where the active item(s) are activated after the conductor has IsActive enabled.

In #789 it was also discussed to add something like BeforeActivate and AfterActivate.
I added a OnInitializedAsync() to adress this as well. I didn't touch the OnViewLoaded (it was wished to make this async), this looks more complicated.

@Yinimi
Copy link
Author

Yinimi commented Apr 2, 2024

If the next release is 5 then it would also be ok to rename the methods. (OnActivate and OnInitialize)
Eventually OnActivate => BeforeActivate, OnActivated => OnActivate (to make things as complicated as possible)

@vb2ae vb2ae self-assigned this Apr 7, 2024
@vb2ae
Copy link
Member

vb2ae commented Apr 7, 2024

Yes the next release is version 5

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the OnActivated name better but could you leave OnActivate and mark it as obsolete? This will keep the amount of code we break when someone updates the caliburn micro version in their project to a minimum

@Yinimi
Copy link
Author

Yinimi commented Apr 8, 2024

I added the obsolete messages

@Yinimi
Copy link
Author

Yinimi commented Apr 9, 2024

I think #764 Is also resolved with this change

@a44281071
Copy link

asp.net Blazor use void OnAfterRender() and Task OnAfterRenderAsync() for view update. And use void OnInitialized() and Task OnInitializedAsync() for init load.

ASP.NET Core Razor component lifecycle:

Component initialization

@Yinimi
Copy link
Author

Yinimi commented Apr 19, 2024

If I read the build pipeline log correct the android 28 sdk is missing? Is the pipeline running on a specific machine with a build agent? Then it would probably be required to install it there manually

@vb2ae
Copy link
Member

vb2ae commented Apr 21, 2024

Working on a fix for android version in another branch

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

3 participants