Closed noname-developer closed 4 years ago
The best solution is to have a method with a list parameter and AddToEndSingleStrategy
:
void showMenuItems(List<MyMenuItem> items);
It's a better abstraction and works fine with Moxy.
A loop in presenter is not a good idea, because it makes Presenter more complicated and forces you to have an additional method in View, like clearMenuItems()
. Also it's hard to make this work correctly ViewState strategies, as you've already found out.
Thanks for your reply! I will use your recommendation. I also wanted to clarify about the cycles, it turns out they are better to use in the view and interactors, bypassing the presenter?
Not sure what you mean, feel free to use cycles anywhere you want) It's just in this particular case using the loop to populate View's menu seems like a bad separation of concerns and doesn't play nice with Moxy.
I understood. Thanks again!
Here is an example code where I call the view method through a presenter in a loop:
Presenter:
Activity:
For example: I need to add 5 menu items. Of these, only the last fifth item will be added. Default Strategy (Tried to add SingleStrategy, AddToEndSingleStrategy, did not help).
Is there a solution to this problem, or is it better for me to transfer the list of necessary items in view and cyclically add them to the menu?
Thank you in advance for your response!