CODEX
Android Studio Kotlin LiveData Function Templates
Two quick hints on Kotlin Live Templates for using Androids LiveData
Live Templates can really make the life of us developers easier. These templates are a built-in tool within Android Studio that allows you to write pre-defined code snippets that let you add parameters while typing and are compatible with the IDEs auto-complete function (IntelliSense).
In one of my recent articles, I wrote an in-depth article about this tool and how it can facilitate your everyday life as an Android Developer. If you have no experience with Live Templates at all, I highly recommend reading that article first.
In this article, I propose two quick Live Templates that you can easily add to your Live Template collection and that can really make your everyday life as a developer easier.
MutableLiveData Live Template
The pattern for declaring a MutableLiveData as a private variable and then exposing a LiveData as a public variable is probably one of the most recurring tasks you do when it comes to the task of writing the ViewModel
implementations.
You set your new values for the LiveData
by calling the private variable and from outside you can only access…