Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StateFlow observable preferences #6

Open
Volatile-Memory opened this issue Jul 23, 2020 · 2 comments
Open

StateFlow observable preferences #6

Volatile-Memory opened this issue Jul 23, 2020 · 2 comments

Comments

@Volatile-Memory
Copy link

With StateFlow now available and the .stateIn() operator coming soon, it would be nice to be able to delegate sharedpreferences to a MutableStateFlow so that we can also observe the preference changes.

Interfaces could expose
var observablePref: StateFlow<T>
properties if the consumer is interested in change notifications in addition to the standard
var pref: T

and creating test doubles with these interfaces would just implement with a MutableStateFlow(default = T) builder.

I had started an implementation of this myself before I found that this library already does the first part.
Would you be willing to incorporate such a feature in this library?
Are PRs encouraged or is this something you would want to implement yourself?

@Unlimity
Copy link
Owner

Hey there, thanks for reaching out!
I'm always all in for coroutines and it's features and contributions are highly appreciated.
So if you have an implementation ready, please don't hesitate to create PR.

@Unlimity
Copy link
Owner

Although I might point out that in case of StateFlow you will have to make the property itself immutable and promote mutable flow:

val myPreference: MutableStateFlow<T>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants