Suppose I am Observing a LiveData in a Fragment and I want to remove observer after I received the data.
eg:
val testLiveData = MutableLiveData<String>()
and Observing as:
testLiveData.observe(this, Observer<String> {
        //TODO://Remove this Observer from here
        //testLiveData.removeObserver(this)
    })
How can I do that? Calling "this" is giving me an instance of the Fragment instead of the current Observer.
However, I can do like this.
 testLiveData.observe(this, object : Observer<String>{
        override fun onChanged(t: String?) {
            testLiveData.removeObserver(this)
        }
    })
Is there any way to do the same in SAM?
 
    