Created
July 13, 2019 18:03
-
-
Save harmittaa/4cbd3c9529d7a7c25245124a4ac29d7c to your computer and use it in GitHub Desktop.
Koin 2.0 and Retrofit 2.6.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.liveData | |
import com.github.harmittaa.koinexample.model.Weather | |
import com.github.harmittaa.koinexample.model.WeatherRepository | |
import org.koin.dsl.module | |
val viewModelModule = module { | |
factory { ExampleViewModel(get()) } | |
} | |
class ExampleViewModel( | |
private val weatherRepo: WeatherRepository | |
) : ViewModel() { | |
val weather: LiveData<Weather> = liveData { | |
emit(weatherRepo.getWeather()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment