What controls the "loading" of feedback in MVP?

I see two main ways to implement โ€œloadingโ€ feedback (for example, the swirly loading icon):

In the presenter:

void displayData() { display.startShowingLoadingIcon(); startLoadingData(); } void onDataLoaded() { display.stopShowingLoadingIconAndDisplayData(data); } 

On display:

 void showData() { startShowingLoadingIcon(); presenter.getData(callback); } Callback callback(data) { stopShowingLoadingIconAndDisplayData(data); } 

I like the second solution because it looks like loading feedback is clearly a UI solution. I do not want my host to be aware of any user interaction. In addition, the first solution allows you to display some flexibility for the case when the user cancels the request, something else appears, etc. On the other hand, the first solution is easier to implement and does not require the display to know about the presenter.

What do you do?

+4
source share
1 answer

I think this belongs to opinion because:

1: The reason you choose things from a view is because you can test it more easily. A simple start / stop showing the load is not like a lot of logic worth writing tests.

2: this function is so specific to the presentation that, in his opinion, the presenter should not even know about it.

3: Since the view is responsible for knowing how to do it yourself, it makes sense that he should know how to display the download icon when necessary.

+2
source

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


All Articles