IOC Lock - Allow circular links

quick question for my MVP implementation:

I currently have the code below, in which both the presenter and presentation are resolved through the container.
The host then calls View.Init to jump to the view.

I was wondering if there is a way to allow the container to set my circular link (view -> presenter, presenter -> view).

class Presenter : IPresenter { private View _view; public Presenter(IView view, ...){ _view = view; _view.Init(this) } } class View : IView { private IPresenter _presenter; public void Init(IPresenter presenter){ _presenter = presenter; } } 

respectfully

Frederick

+3
source share
2 answers

You can use the setter property instead of passing the link to the constructor.

0
source

As long as you put both Presenter and View inside the same csproject, there should be no round link

-1
source

All Articles