Is this any better than having using the backing property that we usually see? This is way has one less property to instantiate so would that make this more memory efficent?
Copy code
protected val titleLiveData = MutableLiveData<String>()
fun getTitleLiveData(): LiveData<String> {
return titleLivaData
}
Nick
10/02/2020, 9:40 PM
Copy code
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?
Nick
10/02/2020, 10:12 PM
compiling down to bytecode, it shows that the traditional approach with the backing field is more efficent.
Traditional approach with backing field: