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?
source share