Android code pieces📱💻
23 subscribers
39 photos
3 videos
6 links
Sample and useful code pieces and tricks for Android and Kotlin
Download Telegram
Here we have a username field and a button that enables when the username is valid.

It starts off empty and so our state is false. Now when the user starts typing, our state correctly updates and our button becomes enabled.

This is where derivedStateOf comes in. Our state is changing more than we need our UI to update and so derivedStateOf can be used for this to reduce the number of recompositions.

It acts similarly to the Kotlin Flows distinctUntilChanged() operator.