Kotlin Multiplatform implementation of Android's Live Data.
1. Create your view model in Multiplatform with Live Data objects:
import com.andrewemery.livedata.MutableLiveData
val currentName: MutableLiveData<String> = MutableLiveData()
2. Interact with your Live Data objects in your Android application:
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
val currentName: MutableLiveData = viewModel.currentName
currentName.observe(this, Observer { name ->
nameTextView.text = name
})
3. Then interact with your Live Data objects in your iOS project as well:
import com.andrewemery.livedata.LifecycleOwner
class Owner : LifecycleOwner { ... }
let owner: Owner()
viewModel.currentName.observe(owner, observer)