Sudhir Singh Khanger
09/19/2018, 4:09 AMclass MainViewModel @Inject constructor(private val movieRepository: MovieRepository) : ViewModel() {
private val movieList: LiveData<List<MovieEntry>> = movieRepository.getMovies()
fun getMovies(): LiveData<List<MovieEntry>> = movieList
}
class MainViewModel @Inject constructor(private val movieRepository: MovieRepository) : ViewModel() {
fun getMovies(): LiveData<List<MovieEntry>> = movieRepository.getMovies()
}
class MainViewModel @Inject constructor(private movieRepository: MovieRepository) : ViewModel() {
init {
fun getMovies(): LiveData<List<MovieEntry>> = movieRepository.getMovies()
}
}
Which of these versions is better and if there's another syntax that might be better?