-
Hey, I would like to ask your opinion on a particular case. In the project, AlbumDetailViewModel and AlbumListViewModel have initially a loading state. This is totally fine since you are making a call to the backend. But let's say, we have a usecase that returns static data so it doesn't make any backend call. In the constructor of the viewmodel (where you pass loading in the viewmodels), we can call the usecase to build the initial viewstate. But I have some concerns about calling the usecase in the constructor because; What if we would like to make a backend call inside of the usecase in the future and we need to make the usecase suspendable? In the constructor, we cannot get viewmodel coroutine scope so it won't be possible. So scalability wise it is not a good place to call the usecase. We could also pass Loading state initially and then call the usecase later but this is also not desired since we are loading anything. I really wonder how would you approach that problem. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
"We could also pass Loading state initially and then call the usecase later but this is also not desired since we are loading anything" - depends on how you look at things. You could consider this loading state as "loading data" state and also as a "screen preparing" state. |
Beta Was this translation helpful? Give feedback.
"We could also pass Loading state initially and then call the usecase later but this is also not desired since we are loading anything" - depends on how you look at things. You could consider this loading state as "loading data" state and also as a "screen preparing" state.