Just saw that a new <https://cs.android.com/androi...
# compose
s
Just saw that a new onRectChanged modifier was created. What are the use cases for such a modifier? And provided you do not use the debounce/throttle params, when would one use this over onPlaced or onGloballyPositioned (depending on what info you need)?
👀 1
r
It is part of a new set of APIs to track visibility/occlusion of nodes. To measure impressions for instance
s
I think it is intended to be a more performant replacement for onGloballyPositioned as well
😍 4
🙌🏻 1
🙌🏾 1
r
If you need to track things like scrolling and such, yes absolutely
s
Which use cases would onGloballyPositioned still be useful for then? Is it just a strictly better version of it, or did it have to compromise on some information it provides to you to get that better performance?
s
I think it is a strictly better version, but maybe I am missing some cases
a
Is there a phase ordering guarantee for
onRectChanged
?
Ah “This will be called after layout pass.” (reading the docs closer)
s
g st
z
omg does this mean
focusable()
can finally stop observing
onGloballyPositioned
?
r
The author says “yes please” to the question of “should folks use onRectChanged instead of onGloballyPositioned”. We’ll try though to implement onGloballyPositioned on top of onRectChanged
🙌🏻 1
🙌 3
🙌🏾 1
z
this is exciting!
s
Well, I am really glad I asked! Thanks for all the info everyone
b
Really excited for this one, I was about to dive into the weeds of benchmarking a modifer we use for impression analytics that uses
onGloballyPositioned
and here you just offer me a solution to all my concerns with our current implementation ❤️
r
There's gonna be APIs on top of this specifically to let you know about visibility. That's what you'll want to use
🦠 2