Last active
February 19, 2020 14:33
-
-
Save fluxtah/989119242c1a25e35ae232f684c368fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MyViewModel : BaseViewModel() { | |
val data: LiveData<String> = MutableLiveData() | |
fun load() { | |
data.value = "Hello, World" | |
} | |
} | |
class MyActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val vm = ViewModelProviders.of(this).get(MyViewModel::class.java) | |
vm.data.observe(this, Observer { | |
Toast.makeText(this, it, Toast.LENGTH_SHORT).show() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment