-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add StateFlow<T>.onSubscription #4275
Comments
Sure, this makes sense, thanks! Would you like to open a PR with this code (+ documentation + tests)? |
I'd be glad to! I hope to deliver the changes in the next few days. |
Done! The documentation is copy-pasted from SharedFlow.onSubscription, I've only replaced the word "shared" with "state" in the first line. About the tests, I saw that there's already testOnSubscriptionWithException (which now is using the new |
Good job, thanks! Let's continue under #4380, as this starts to be about the implementation and not the issue itself. |
Use case
The current
SharedFlow<T>.onSubscription
implementation returns aSharedFlow<T>
, which means losing type information when calling it from aStateFlow<T>
. It would be nice to have aStateFlow<T>.onSubscription
counterpart forStateFlow<T>
, thus avoiding the aforementioned issue.The Shape of the API
Unless there are implementation details I'm unaware of, the API could be copy-pasted from the
SharedFlow<T>.onSubscription
implementation and adapted to work withStateFlow<T>
:Prior Art
The text was updated successfully, but these errors were encountered: