Skip to content

Instantly share code, notes, and snippets.

@cp-hardik-p
Created August 29, 2022 10:37
Show Gist options
  • Save cp-hardik-p/eeb7d8e8981045d33471aabb7c59746b to your computer and use it in GitHub Desktop.
Save cp-hardik-p/eeb7d8e8981045d33471aabb7c59746b to your computer and use it in GitHub Desktop.
// get the user's age
val userAgeFlow: Flow<Int> = context.dataStore.data.map { preferences ->
preferences[USER_AGE_KEY] ?: 0
}
// get the user's name
val userNameFlow: Flow<String> = context.dataStore.data.map { preferences ->
preferences[USER_NAME_KEY] ?: ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment