https://kotlinlang.org logo
#android
Title
# android
a

Adam Hurwitz

06/17/2019, 7:04 PM
I'd love to know if anyone has explored the Unidirectional Data Flow for Android? I took a unique approach implementing it with LiveData + Kotlin as opposed to RxJava. A few major Kotlin benefits with this pattern are the
Sealed class
and the shallow
.copy(..)
function. I'd love any feedback on this new approach! 🙂 🤖 Medium - https://hackernoon.com/android-unidirectional-flow-with-livedata-bf24119e747 YouTube -

https://youtu.be/Elp-Z-pQTpM

😲 3
b

bloder

06/17/2019, 7:30 PM
Undirectional Data Flow It's a great approach, but it's going to be better when
Compose
gets released and actually I'm using coroutines (
Flow
extension) to implement a kind of Redux implementation https://gist.github.com/bloderxd/830e92702b92c4cf0906c57e54726e14
but it's a good approach, I'm just pretty excited about compose to use better
s

sngrekov

06/17/2019, 9:44 PM
There is no need to wait for Compose to try Declarative UI on Android, it is already there
b

bloder

06/17/2019, 10:20 PM
how do u try that without Compose? Let's suppose you have this:
Copy code
fun render(state: MyState) {
 
}
this
MyState
is the view state, how do u render that today properly with no imperative way? 🤔
of course u can build tools for that, but just with android framework, how do u do?
using databinding?
s

sngrekov

06/18/2019, 8:26 AM
Different ways. You can use declarative UI libraries like Litho, Anko, Anvil which allows exactly this. But if you still prefer plain old xml for some reason, you can mimic this render() method by your own.
b

bloder

06/18/2019, 12:54 PM
Yeah I can create tools for that but I'm waiting some kind of official support to that.
s

sngrekov

06/18/2019, 8:08 PM
My point is that you don't even need to create one, they are already there. But yes, they are not "official"
a

Adam Hurwitz

06/27/2019, 6:52 PM
Hey @bloder, @sngrekov, I am just seeing these messages now. I switched from Slack web to the app so that I'll receive realtime notifications moving forward! 📬
@bloder, Thank you for the feedback! I haven't explored
Compose
yet. I've started using Coroutines to handle basic threading use cases, but need to look into the
Flow
extension. Your code sample is interesting!