getUserDataPreferences

Observes the complete user preferences data.

This function returns a cold Flow that emits the current UserDataPreferences whenever any preference value changes. The flow is backed by DataStore and provides reactive updates to all preference changes.

When to Use

  • Observing user session data (ID, name, profile picture)

  • Tracking theme preferences for UI updates

  • Monitoring dynamic color settings

Example

// In ViewModel
val isDarkMode = userPreferencesDataSource.getUserDataPreferences()
.map { it.darkThemeConfigPreferences == DarkThemeConfigPreferences.DARK }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)

Return

A Flow emitting UserDataPreferences on every preference change. The flow never completes unless DataStore is cleared.