android10 / Android-CleanArchitecture-Kotlin

This is a movies sample app in Kotlin, which is part of a serie of blog posts I have written about architecting android application using different approaches.
https://fernandocejas.com/2018/05/07/architecting-android-reloaded/
4.64k stars 921 forks source link

GlobalScope in UseCase layer is antipattern? #117

Closed R-Ashh closed 2 years ago

R-Ashh commented 2 years ago

Hello guys, first I need to thank you for this awesome sample, there's something I need to make sure that I've been seeing topics about GlobalScope and how you shouldn't use it for every task in the app to avoid memory leaks and resource shortage, So, what is your recommendation for make some improvement on UseCase layer?

crjacinro commented 2 years ago

From Kotlin 1.5, Global scope is considered delicate and should not be used. We can create a custom scope instance but make sure to cancel it on appropriate times.

lrnrzg commented 2 years ago

You can see more: https://developer.android.com/kotlin/coroutines/coroutines-best-practices#global-scope