I want to use Lambda expression but I am getting s...
# android
n
I want to use Lambda expression but I am getting such error. Can anyone help ?
k
this is what I do in my projects:
Copy code
fun <D : Any, T : LiveData<D>> T.observeWith(owner: LifecycleOwner, receiver: (D) -> Unit) {
    observe(owner, Observer<D> {
        if (it != null) {
            receiver(it)
        }
    })
}
and then you can call this function in your code like this:
loginViewModel.progress().observeWith(this, this::onProgress)
n
Woow super thanks bro