Reputation: 2108
I have a ViewManager class that manages Views instances. It is used by the ShellViewModel and by many other ViewModels, and it has to injected through the constructor. The ShellViewModel has the ViewManager injected. If I create a new ViewModel using a factory, who should provide the factory with the ViewManager in order to inject it into the new VM?
what's the best way? Thank you all!
Upvotes: 0
Views: 128
Reputation: 34359
The best way if you're using MVVM is to use an MVVM framework. To answer your question, you would want the view manager to be injected via the factory constructor, rather than the factory method, so option 1.
Really though you don't want to be managing view instances yourself - rather use a framework which has already done all of the work for you, rather than reinventing an inferior wheel.
Upvotes: 1