android / codelab-android-datastore

Apache License 2.0
228 stars 105 forks source link

Adjust DataStore param in UserPreferencesRepository #28

Closed diegocarloslima closed 2 years ago

diegocarloslima commented 3 years ago

On the Working with Preferences DataStore codelab section 6. Persisting data in Preferences DataStore, there is the following snippet of code:

class UserPreferencesRepository(
    private val userPreferencesStore: DataStore<UserPreferences>,
    context: Context
) { ... }

I guess the generics type should be Preferences and not UserPreferences. Otherwise, it gives a type mismatch error when trying to instantiate the UserPreferencesRepository

heskadon commented 3 years ago

Yes should be like :

class UserPreferencesRepository(
    private val userPreferencesStore: DataStore<Preferences>,
    context: Context
) { ... }
mmoczkowski commented 2 years ago

Thank you, fix is underway. Issue can be tracked in #45