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

Tristan

01/02/2020, 3:53 PM
Hello, I read it will be possible to use Jetpack Compose outside of android (community effort though), and I was wondering if it would be possible to do so with any other jetpack library (room, livedata, for instance)
m

mbonnin

01/02/2020, 3:54 PM
It's not answering the question directly but you can have a nice mpp equivalent of room and livedata with sqldelight and coroutines
t

Tristan

01/02/2020, 3:56 PM
Sure it would definitely work. 👍
f

Foso

01/02/2020, 5:14 PM
AFAIK Compose could be used outside of Android, because the Android Team is developing it with the Kotlin multiplatform plugin and the core runtime will have no Android specific code and is written with "common" Kotlin. Other Jetpack Libraries often rely on other Android libraries and parts are written in Java. So, they can't easily be compiled to other targets. As Martin said, the best option for now is to look at mpp equivalents.
👍 2
k

Kurt Renzo Acosta

01/02/2020, 5:56 PM
It would be like Flutter then if that's the case. I think it's better to just use Compose on Android, SwiftUI on iOS, then whatever is better for each platform. For Room, you could use SQLDelight, as mentioned above. For LiveData, you can use Flows. A
ConflatedBroadcastChannel
behaves like a
MutableLiveData
Instead of
setValue
or
postValue
, you can use
offer
then you can expose it as a
Flow
through
asFlow
And to consume it, instead of
fun LiveData.observe()
, you can use
fun Flow.collect()
👍 1