Search code examples
androidkotlinarchitecturekotlin-coroutinesuse-case

Using kotlin coroutines in clean architecture


I am a beginner android developer. I'm just starting to learn clean architecture. Is it practical to have kotlin coroutines dependency in domain layer? As I know domain don't need have dependencies.

I want to use coroutine inside my UseCase class, but I don't know if it's right


Solution

  • As the developers.android documentation says it is ok if you follow the caller's lifecycle. In almost every case, it is ViewModel. But still, you should call it from your ViewModel if you can.