Last week I shared my experience of migrating from RxJava 2 -> 3. This time, I have a quick tidbit and some resources on Kotlin scope functions.
Kotlin has a set of handy functions all with slightly different behavior but designed to help make your code easier to read and maintain:
It can be a little confusing to figure out which of these to use in each situation, but lucky for us, the authors of the Kotlin language have some official recommendations which they have shared on this page:
Furthermore, this helpful chart from Jose Alcérreca (Android Developer Relations @ Google) that was shared by one of my coworkers pairs some of these concepts with code snippets:
Finally, no discussion of these scoping functions would be complete without mentioning this article by Digital Products' own Anton Spaans:
I hope you learned some things and feel better equipped to use the Kotlin scoping functions in your own project! Do you have your own ways of remembering which of these functions to apply when? (unintended joke there) - let me know in the comments! And, please follow me on Medium if you're interested in being notified of future tidbits.
This tidbit was originally delivered on June 19, 2020.