JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

Make livedata available on Apple targets #4955

Closed Mats-Hjalmar closed 2 weeks ago

Mats-Hjalmar commented 2 weeks ago

I have an App where we are using MutableStateFlow to share data to the UI. Problem is that we need to update the view when the same value is emitted on the flow.

pablichjenkov commented 2 weeks ago

Instead of a StateFlow use a SharedFlow with repeat 1. You will also have to update the Update Policy in your compose State, because compose State also don't Emit events on the same event. Bottom line you should change your design into something that represents your state not depending on this state updates. That would be better for performance too.

MatkovIvan commented 2 weeks ago

Thanks @pablichjenkov for reply regarding the specific issue.

I'll just add regarding porting LiveData to multiplatform - there is no plan to do that. Obvious reasons are: