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
const val PREFERENCE_NAME = "my_preference" | |
class DataStoreRepository(context: Context) { | |
private object PreferenceKeys { | |
val name = preferencesKey<String>("my_name") | |
} | |
private val dataStore: DataStore<Preferences> = context.createDataStore( | |
name = PREFERENCE_NAME |
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
//1 .- We use callbackFlow , this is like channelFlow and will propagate our data to our viewmodel | |
override suspend fun getVersionCodeRepo(): Flow<Resource<Int>> = callbackFlow { | |
// 2.- We create a reference to our data inside Firestore | |
val eventDocument = FirebaseFirestore | |
.getInstance() | |
.collection("params") | |
.document("app") | |
// 3.- We generate a subscription that is going to let us listen for changes with |