Database handlers
Usage
- Add JitPack to your project build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency in the application build.gradle
dependencies {
implementation "com.github.FunkyMuse.KAHelpers:database:$utilsVersion"
}
- Simple usage
//inside your ViewModel
private val favoritesData: MutableLiveData<DBResult<List<MyModel>>> = MutableLiveData()
val favorites: LiveData<DBResult<List<MyModel>>> = favoritesData
private fun getAll() {
makeDBCallFlow(favoritesData) {
favoritesRepo.getAll()
}
}
//your getAll method
@Query("select * from myFavorites") fun getAllFavorites(): Flow<List<MyModel>>