Last active
April 5, 2024 14:59
-
-
Save nizarfadlan/300defaf7700d060e1d933f7a6e556e6 to your computer and use it in GitHub Desktop.
Repository
This file contains hidden or 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
class GithubRepository private constructor( | |
private val favoriteDao: FavoriteDao | |
) { | |
suspend fun insertFavoriteUser(data: FavoriteUser) { | |
favoriteDao.insertFavorite(data) | |
} | |
suspend fun deleteFavoriteUser(username: String) { | |
favoriteDao.deleteFavorite(username) | |
} | |
fun isExistsFavorite(username: String) { | |
return favoriteDao.isExistsFavorite(username) | |
} | |
fun getAllFavorite() { | |
return favoriteDao.getAllFavoriteUsers() | |
} | |
companion object { | |
@Volatile | |
private var instance: GithubRepository? = null | |
fun getInstance( | |
favoriteDao: FavoriteDao | |
): GithubRepository = | |
instance ?: synchronized(this) { | |
instance ?: GithubRepository(favoriteDao) | |
}.also { instance = it } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment