Hi, everyone I used MutableLiveData in Android de...
# multiplatform
n
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
Only if you provide own implementation. It shouldn’t be too hard to do
k
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
Thank you for your answers
I will take a look on git links
j
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
You haven’t gotten to native yet. It’s different. Long story
j
My bad