MVP - Dependency Injection and Model

Given that the presentation uses the presenter, and in the presenter you have a model.

How do you introduce a model into a presentation? If I were to enter it at the "View" level, you returned to the square with the business logic in the view - otherwise the view should not know about its model.

Any tips?

+3
source share
1 answer

You must keep in mind the passive presentation pattern. In the Supervising Controller template, the view is associated with the model for synchronization.

. . , , Main. , #.

static void Main(string[] args)
{
    Model model = new Model();
    View view = new View();
    Presenter presenter = new Presenter(view, model);
}

public Presenter(IView view, IModel model)
{
    this.View = view;
    this.View.Presenter = this;
    this.Model = model;
}

, . , , , , IoC . IoC , .

+3

Source: https://habr.com/ru/post/1709468/


All Articles