reactivedroid/TvFlix

calling retrofit API Dispatchers.main

minion06 opened this issue · 1 comments

** ViewModelscope.launch will launch in Dispatchers.main context check below lines in
HomeViewModel.kt does it affect performance

viewModelScope.launch(coroutineExceptionHandler) {

        // Get shows from network, suspend function in retrofit will launch a new coroutine with IO dispatcher .

        *calling in Dispatchers.Main does it affect performance *val episodes = tvMazeApi.getCurrentSchedule(COUNTRY_US, currentDate)**

        // Return the result on main thread via Dispatchers.Main
        homeViewStateLiveData.value = Success(HomeViewData(getShowsWithFavorites(episodes, favoriteShowIds)))
    }

@minion06 No it won't affect performance. viewModelScope has been created as an extension function to ViewModel which helps in cancelling tasks automatically when the ViewModel is destroyed