Hello :slightly_smiling_face: I’m a little bit stu...
# android
l
Hello 🙂 I’m a little bit stuck on a lambda, which I tried to use from itself
Copy code
val listener = {
            lottieAnimationView.viewTreeObserver.removeOnGlobalLayoutListener(listener)    <<<---- here's the problem
        }
        lottieAnimationView.viewTreeObserver.addOnGlobalLayoutListener(listener)
Can anybody help on this please ?
d
i don’t think it can be done with a lambda. i do something like:
Copy code
viewTreeObserver.addOnGlobalLayoutListener(object: ViewTreeObserver.OnGlobalLayoutListener {
			override fun onGlobalLayout() {
				viewTreeObserver.removeOnGlobalLayoutListener(this)
			}
		})
(untested)
b
It should be doable with a lambda and a fix-point combinator, but whether Kotlin supports that... 🤷
^ good read on topic of self referencing in lambda (and why it's not supported, and won't be)