https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

Nikolai

11/07/2018, 3:36 AM
Hi, everyone I used MutableLiveData in Android development, does anyone know any equivalent in kotlin-native that can be used in multiplatform development? To implement similar behavior - observable variable.
g

gildor

11/07/2018, 3:44 AM
Only if you provide own implementation. It shouldn’t be too hard to do
k

kpgalligan

11/07/2018, 6:11 AM
I created an implementation. https://github.com/touchlab/knarch.threads
👍 4
Ties into sqldelight so you can do reactive data updates
To be clear, I intended that implementation to be temporary. As native coroutines and multithreading mature I expect something else to emerge, but it works. If there's a desire for something like LiveData, it's pretty straightforward to do.
n

Nikolai

11/07/2018, 10:23 AM
Thank you for your answers
I will take a look on git links
j

josephivie

11/08/2018, 5:51 AM
The ObservableProperty interface from there is actually just a mutable collection of lambdas with T as an argument. Slap a
value:T
on that interface and you have your immutable version of the interface. Make a mutable copy of the interface that has value as a var instead, and make the implementation call all of the lambdas whenever it is changed. Use the Kotlin library to its full potential.
k

kpgalligan

11/08/2018, 5:56 AM
You haven’t gotten to native yet. It’s different. Long story
j

josephivie

11/08/2018, 5:59 AM
My bad
7 Views