Skip to content

Modify StateFlow operators to return StateFlow instead of Flow #2169

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

Closed
Talhaali00 opened this issue Jul 28, 2020 · 2 comments
Closed

Modify StateFlow operators to return StateFlow instead of Flow #2169

Talhaali00 opened this issue Jul 28, 2020 · 2 comments

Comments

@Talhaali00
Copy link

I'm running into a minor annoyance when trying to combine StateFlows because all of the operators for StateFlow return Flow. This is solved at the moment by casting all of my operations back to StateFlow but it would be nice if I didn't have to do a cast every time.

val test1 = MutableStateFlow(1)
val test2 = MutableStateFlow(2)
val test3: StateFlow<Int> = test1.map { it * 2 } as StateFlow<Int>
val test4: StateFlow<Int> = test1.combine(test2) { first, second -> first + second } as StateFlow<Int>
@fvasco
Copy link
Contributor

fvasco commented Jul 28, 2020

Duplicate #2008 #2081

@Talhaali00
Copy link
Author

Oh sorry, I didn't see anything on this topic. Thanks for linking the other posts.

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