Skip to content

Instantly share code, notes, and snippets.

@egorikftp
Created August 22, 2021 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egorikftp/323c77a5e6cad4ababd64c71cc411c7e to your computer and use it in GitHub Desktop.
Save egorikftp/323c77a5e6cad4ababd64c71cc411c7e to your computer and use it in GitHub Desktop.
val EXAMPLE_COUNTER = intPreferencesKey("example_counter")
val exampleCounterFlow: Flow<Int> = context.dataStore.data
.map { preferences ->
// No type safety.
preferences[EXAMPLE_COUNTER] ?: 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment