Ad

Transformations.map With ViewModel And LiveData In Androidx (issue)

Ad

Answer

You have imported the wrong function type. it should be androidx.arch.core.util.Function and not import java.util.function.Function

In your Activity: if your ViewModel is kotlin you should reference the livedata like hotStockViewModel.hotStockLiveData since it's a property.

On JVM the properties such as "hotStockLiveData" will have a "get HotStockLiveData" and "setHotStockLiveData" which from kotlin is called like hotStockViewModel.hotStockLiveData, but in JAVA you may use hotStockViewModel.getHotStockLiveData() That's why you can't define a "getHotStockLiveData()" function in the viewModel.

Ad
source: stackoverflow.com
Ad