Created
July 13, 2019 14:53
-
-
Save harmittaa/d7d6b48884e7c344ba1151a1c33babe6 to your computer and use it in GitHub Desktop.
Koin 2.0 example ViewModel
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.MutableLiveData | |
import androidx.lifecycle.ViewModel | |
import com.github.harmittaa.koinexample.persistence.ExamplePreferences | |
import org.koin.dsl.module | |
val viewModelModule = module { | |
factory { ExampleViewModel(get()) } | |
} | |
class ExampleViewModel(preferences: ExamplePreferences) : ViewModel() { | |
val fragmentContent = MutableLiveData<String>() | |
init { | |
fragmentContent.value = preferences.getFragmentContent() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment