Nick
10/02/2020, 9:37 PMprotected val titleLiveData = MutableLiveData<String>()
fun getTitleLiveData(): LiveData<String> {
return titleLivaData
}
this._titleLiveData = new MutableLiveData();
this.titleLiveData = (LiveData)this._titleLiveData;
This is what it compiles down to if there is a backing property, since it’s just copying it over its just as efficent, right?LINENUMBER 33 L0
ALOAD 0
GETFIELD com.blahblahblah.MyViewModell.title : Landroidx/lifecycle/LiveData;
ARETURN
Approach with the getter function:
LINENUMBER 29 L0
ALOAD 0
GETFIELD com.blahblahblah.MyViewModell._title : Landroidx/lifecycle/MutableLiveData;
CHECKCAST androidx/lifecycle/LiveData
ARETURN
The traditional approach doesn’t have the extra cast in it. Memory is the same it appears.