Created
November 12, 2024 15:49
-
-
Save anitaa1990/03706aa8562a742ce1de9ecefdacfe26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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