ok nm this works (and is quite pretty): ``` ...
# android
c
ok nm this works (and is quite pretty):
Copy code
conversionViewModel?.getConversion()?.observe(this, Observer<Conversion>{ conversion ->
            println("observer called with conversion: $conversion")
        })
and simple.
a
You can also do:
Copy code
conversionViewModel?.getConversion()?.observe({ lifecycle }) {
    println("observer called with conversion:  $it")
}
👍 1
btw, normally you’d be able to
observe(this) { print(it) }
, but for some reasons mentioned here https://stackoverflow.com/q/46542037/1916449 in this case it doesn’t work
I guess it might be better to use the objects version (yours) instead of lambda version (mine), because the latter will generate an extra anonymous class that just forwards the call to the lifecycle owner
👍 1
c
I actually like the object version though it’s a bit more verbose. Bottom line is the fact that these listeners can be wired up to a real viewmodel that is natively supported is the great thing here.