https://kotlinlang.org logo
Title
h

henrytao

05/20/2018, 1:55 AM
Hi all, if you are using LiveData, these extensions can be useful
val liveData: MutableLiveDataBoolean = MutableLiveData()
liveData
  .distinct()
  .filter { it == false }
  .map { true }
  .nonNull()
  .observe(lifecycleOwner, { result ->
    // result is non-null and always true
  })
Check it out: https://medium.com/@henrytao/chaining-livedata-like-rxjava-with-kotlin-extension-e3a2c15ac11
👍 3
g

ghedeon

05/21/2018, 5:51 PM
nice job! What would be the final goal of such effort? To get rid of RxJava? I'm using both just to be in sync with android updates, but honestly, it's hard to justify LiveData presence when you already have Rx. The out of the box lyfecycle management is just a matter of one line from AutoDispose library or similar.