Closed vchernyshov closed 4 years ago
hi! we just using LiveData approach long time, before start use coroutines :) your suggestion is good. I will add it to lib
@Alex009 If I understood correct Flow based approach can replace LiveData and simplify implementation as no need to create separate LiveData class for iOS. I Have tried to modify your sample with State it works but Flow class can't be recognised at Xcode project.
what do you mean "Flow class can't be recognised at Xcode"? are you try use export coroutines dependency?
https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#exporting-dependencies-to-binaries
Flow as class should be recognised at Xcode. Problem can be only with suspend
functions and blocks - they now will be deleted from header of framework
I think this is relevant: https://github.com/Kotlin/kotlinx.coroutines/pull/1354. Looks like the coroutines team is already busy with a Flow that holds a data.
@NahroTo As I understood it is only lightweight version on channel. And it is a good approach to have wrapper around it, you can change internals and external API will be the same
@Alex009 Maybe it is connected with with suspend function
Kotlin coroutines 1.3.6 introduces StateFlow, which is a reactive coroutine value holder. I think we can close this issue. Check it out: https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.3.6
as already said - https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.3.6 have StateFlow with implementation of idea from this issue. issue can be closed
Why you don't use coroutines flow to implement reactive value holders instead of LiveData?
I mean something like this: State: https://gist.github.com/vchernyshov/d661e153e768915c5a2b3a23a7338b1c ViewModel: https://gist.github.com/vchernyshov/cfd39b16b6e022188b97887f3f4c3351