Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created November 12, 2024 15:49
Show Gist options
  • Save anitaa1990/03706aa8562a742ce1de9ecefdacfe26 to your computer and use it in GitHub Desktop.
Save anitaa1990/03706aa8562a742ce1de9ecefdacfe26 to your computer and use it in GitHub Desktop.
// Domain Layer (Use Case)
class GetUserProfile(private val userRepository: UserRepository) {
suspend operator fun invoke(userId: String): User {
return userRepository.getUserById(userId)
}
}
// Data Layer (Repository Implementation)
class UserRepositoryImpl(private val apiService: ApiService, private val userDao: UserDao) : UserRepository {
override suspend fun getUserById(userId: String): User {
// Decide whether to fetch data from network or local database
return apiService.getUserById(userId)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment