Skip to content

Kotlin Multiplatform implementation of Android's Live Data

Notifications You must be signed in to change notification settings

andrewemery/livedata

Repository files navigation

Live Data [work in progress]

Kotlin Multiplatform implementation of Android's Live Data.

Introduction

 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)

About

Kotlin Multiplatform implementation of Android's Live Data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages