Caliburn.Micro Screen and Conductor Lifecycle documentation
Asked Answered
L

1

8

Does anyone know a source for an overview of the Caliburn.Micro Screen/Conductor Lifecycle? For example a sequence diagram / flow chart that describes their call order/dependencies and the conditions when they get called or not? Until now I have primarily uses OnViewLoaded but I want to know which are called a second time (when shown again) etc. I didn't found a good documentation about the Screen Lifecycle yet.

And yes, I know it is Open Source and I can read the source code or debug that (what I'm doing at the moment)... just thought that this requirement is somewhat basic to work with Caliburn.Micro and there must be something already done and I don't need to create that overview on my own. Maybe the answer might help someone else, too. ;-)

For example, when derriving from Conductor.Collection.OneActive there are the following (and even more) methods that seem to play a role in the lifecycle and can be overloaded:

protected virtual void OnInitialize()

protected virtual void OnActivate()

protected virtual void OnActivationProcessed(IScreen item, bool success)

protected virtual void OnDeactivate(bool close)

protected virtual void OnViewAttached(object view, object context)

protected virtual void OnViewLoaded(object view)

protected virtual void OnViewReady(object view)

What I have seen so far this seems to be the order (app startup to exit):

  1. OnViewAttached
  2. OnInitialize
  3. OnActivate
  4. OnViewReady
  5. OnViewLoaded
  6. OnActivationProcessed
  7. OnDeactivate

But what are the bullet points for each method? E.g. when is the datacontext set, the style template applied to the view and ready to be shown? When is the view shown? (difference between ViewReady and ViewLoaded?)

Lancelancelet answered 11/8, 2016 at 14:5 Comment(0)
M
1

Not a full answer but it is a start, from the documentation of this project, which is worth reading, you can find bullet points for some of those events:

  • OnInitialize – Override this method to add logic which should execute only the first time that the screen is activated. After initialization is complete, IsInitialized will be true.
  • OnActivate – Override this method to add logic which should execute every time the screen is activated. After activation is complete, IsActive will be true.
  • OnDeactivate – Override this method to add custom logic which should be executed whenever the screen is deactivated or closed. The bool property will indicated if the deactivation is actually a close. After deactivation is complete, IsActive will be false.
  • OnViewLoaded – Since Screen implements IViewAware, it takes this as an opportunity to let you know when your view’s Loaded event is fired. Use this if you are following a SupervisingController or PassiveView style and you need to work with the view. This is also a place to put view model logic which may be dependent on the presence of a view even though you may not be working with the view directly.

There is also a good explanation on the parameters being sent to the methods, and many other topics for the layers of the screens and their life cycle.

Mithridate answered 17/5, 2018 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.