Roar Gronmo
12/08/2019, 12:48 PMAdam Powell
12/08/2019, 2:50 PMAdam Powell
12/08/2019, 2:50 PMAdam Powell
12/08/2019, 2:51 PMFlow
is a bit of a challenge at the moment due to some incompatibilities between the version of the IR compiler the latest compose plugin is using and generating suspending code, but some clever module separation can work around it for now. We're pretty anxious to see these bugs get fixed soonAdam Powell
12/08/2019, 2:52 PMLiveData
is a little bit easier, let me see if I can dig up the snippet to use as an observe()
effect for itAdam Powell
12/08/2019, 2:53 PMfun <T> observe(data: LiveData<T>) = effectOf<T?> {
val result = +state<T?> { data.value }
val observer = +memo { Observer<T> { result.value = it } }
+onCommit(data) {
data.observeForever(observer)
onDispose { data.removeObserver(observer) }
}
result.value
}
Adam Powell
12/08/2019, 2:54 PMval currentValue = +observe(myLiveData)
Adam Powell
12/08/2019, 2:55 PMLiveData
value changes, and the LiveData
will have an active observer for the duration of that compositionAdam Powell
12/08/2019, 2:56 PMRoar Gronmo
12/08/2019, 3:01 PMAsh
12/08/2019, 5:34 PMAndrew Kelly
12/09/2019, 7:25 AMAsh
12/10/2019, 5:21 AMAndrew Kelly
12/10/2019, 5:22 AM