Android kotlin series explanation (advanced) LiveData of Jetpack series

<< Return to the general catalog

1. What is LiveData

LiveData is a reactive programming component provided by Jetpack, which can include any type of data and notify observers when the data changes. LiveData is especially suitable for use in combination with ViewModel, although it can also be used in other places alone, but in most cases, it is used in ViewModel

2. LiveData test

The count of the counter is packaged with LiveData , and then observed in the Activity , you can actively notify the Activity of the data change, modify MainViewModel.kt

package com.example.myapplication4

Guess you like

Origin blog.csdn.net/qq_35091074/article/details/129316880