0

I am new to Epoxy and I'm currently trying some use-cases to check if it's a good fit for my project. I understand that the data that are set to a Controller should be immutable.

In my case I have a View with several toggles and checkboxes and I want to keep track of the user's interactions, because based on those interactions I need to create my network request, later on. I have searched a lot in the documentation and sample projects of Epoxy but haven't found an example with the proper way to do such a thing.

What is the correct way for the user's interaction to change the data model that my controller has.

Libathos
  • 3,340
  • 5
  • 36
  • 61
  • Who said "that the data that are set to a Controller should be immutable"? You should pass new items to controller and it'll calculate diff and dispatch them to view. – beigirad Nov 02 '22 at 11:15

1 Answers1

0

After a lot of searching, it turns out that you should copy (shallow not deep) the list past to the controller, and change the data (interacted by the user) to the new one, and the pass it again to the controller. I just put this answer here for anyone that stumbles upon this post

    val newList = ArrayList(originalList.map { it.copy() })
    newList.find { it.id == event.data.id }?.isMainToggleOn = !event.data.isMainToggleOn
    controller.setData(newList)
    originalList = newList
Libathos
  • 3,340
  • 5
  • 36
  • 61
  • If i do this, my view is fully refresh. So, In a conversation message list, I am once again to the top which is a very awful effect – Andracchi Mar 22 '23 at 22:26