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

getUserStream should expose Flow<User> #5

Open
ZakTaccardi opened this issue Oct 6, 2019 · 0 comments
Open

getUserStream should expose Flow<User> #5

ZakTaccardi opened this issue Oct 6, 2019 · 0 comments

Comments

@ZakTaccardi
Copy link

fun getUserStream(): ReceiveChannel<User> {
return users.openSubscription()
}

This should be a Flow<User>, as UserRepository exposes an API that returns multiple instances of T over time.

ConflatedBroadcastChannel is basically a Flow<T>, as subscribing to it is cold behavior (open a subscription when you start collecting, close it when you stop collecting).

Another downside of ReceiveChannel<T> here is that it leaks how you unsubscribe. Using for(user in getUserStream) to observe would leave an opened channel.

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

1 participant