Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Module initialization problem

$
0
0
Hi,

Based on my understanding you would like a possible workaround in order to import the IModuleManager into the ShellViewModel and properly handle every published event from modules initialization.

One simple way you could achieve this is to remove the publish statements from the initialize() methods, and wait instead until the BootStrapper initialization process finishes. Therefore, you could override the Run() method and publish a BootStrapperInitializationCompletedEvent event when it finishes running base method.

Basically, you would need to perform the following updates from the Modules side:

  • Remove publish statement from each Moduleinitialize() method;
  • Add a suscription on each Module initialize() method for the BootStrapperInitializationCompletedEvent event;
  • Handle the BootStrapperInitializationCompletedEvent event and publish the corresponding Module event that was previously removed from the initialize() method.
And then, from the BootStrapper side you should perform the following:

  • Override Run() method by implementing the base.Run(); statement and publishing the BootStrapperInitializationCompletedEvent event.
The ShellViewModel would remain as you described, with no changes. This way, the BootStrapper would publish an event after everything got initialized, giving the green light to every Module to publish their events, knowing that the ShellViewModel is already suscribed to them.

I hope this helped,
Regards.

Gabriel Ostrowsky
https://blogs.southworks.net/gostrowsky

Viewing all articles
Browse latest Browse all 1878

Trending Articles