I believe it's supposed to be like so:
- The
ViewModel
decides when the navigation happens, the destination, and also the data, if any, to be passed to the destination.
- The
View
performs the actual action, decides on the navigation animation and other UI stuff.
So ultimately we need the logic to be in the ViewModel
and the UI stuff should be the responsibility of the View
.
One way to go about it is to fire an Event
in the ViewModel
when navigation needs to happen. This event should specify the destination and data to be passed if any. The View
subscribes to this event and whenever it is fired, it decides upon the navigation animation and then performs the actual action (the actual act of navigation is a part of the UI) taking into consideration the destination and the data to be passed.