开发者

MVP and Composition

开发者 https://www.devze.com 2023-01-31 15:37 出处:网络
I\'m not shure 开发者_JAVA技巧if I realy understood MVP in the context of composition. Lets say I\'ve got a MainView which is a composite of ViewA and ViewB.

I'm not shure 开发者_JAVA技巧if I realy understood MVP in the context of composition. Lets say I've got a MainView which is a composite of ViewA and ViewB.

I've seen several examples where the View creates the presenter. Now here's my Problem, i'm not realy shure who should create whom.

Should the MainView create the MainPresenter which is a composite of APresenter and BPresenter, or should each view create its own presenter.


If MainView is just a container for both ViewA and ViewB, then it does not need its own presenter, and the sub-views can continue using their individual default presenters.

However, if the MainView also modifies the sub-views behavior, it needs to create a composite presenter and inject it for the sub-views to use instead of their default presenters.

0

精彩评论

暂无评论...
验证码 换一张
取 消