Hello everyone, I'm super new to Android and tryin...
# android
a
Hello everyone, I'm super new to Android and trying to build a App with the mvvm architecture. From the many tutorials on YouTube I could figure out how to use Observerable and LiveData for data from ViewModel to View but how do I send the events of the View to the ViewModel like button clicks?
you can read up on this
p
Some people refer to messages from ViewModel to View
events
and messages from View to ViewModels
actions
. You can call any ViewModel action dispatcher method directly from the ViewModel reference you have in your View. Assuming you dispatch them from the Main Thread you wouldn't need a queue inside the ViewModel. If you plan to dispatch actions to the ViewModel from more than one thread, then you should have an action queue inside your ViewModel that process them one by one. This will avoid multi threading issues. For that you can research for Redux Store in Redux arch. But for simply handling View actions like clicks, direct dispatch is fine.