Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MutableLiveData doesn't apply change

    private var number = MutableLiveData(0)

    fun addOne(){
          number.value?.let { it + 1 }
    }
    

I would like to increase my mutableLiveData by 1 all the time using my function.
But it still shows 0. What could be wrong there ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you are not change live data value …you are just get the value :
you should

number.value = number.value!! + 1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading