Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it okey to call collect within a Composable

So i took a look at this tutorial https://www.youtube.com/watch?v=f_iIMscTNjQ and within it Philip as he is named explains that making network calls in a composable is a bad habbit. But what about getting the results in a Stateflow in a composable is that to a bad habbit? or is that okey. So the question is that when you call collect on a MutableStateFlow is it okey to do that directly in the compose method and not in the a sideEffect block?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not only it is not a bad habit, it is the only way to actually use the result in composable. I wouldn’t expose MutableStateFlow but rather only StateFlow, but the rest is just fine

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading