Can someone explain this new api from compose runt...
# compose
r
Can someone explain this new api from compose runtime 1.10.0 https://android-review.googlesource.com/c/platform/frameworks/support/+/3629910 ? There are
awaitOrScheduleNextFrameEnd
and
awaitOrScheduleNextCompositionEnd()
mentioned in the description, but there are no such functions commited in code. I assume it was renamed to
scheduleFrameEndCallback
but this is not suspending, so can't do what is described.
Currently when I want to execute some action after recomposition I use
SideEffect {}
. How is this new API different?
z
I believe (from glancing at the code) that
scheduleFrameEndCallback
runs its callbacks after the apply phase as well, so after all non-suspending effects have run and the
Applier
has updated the node tree. In contrast with
SideEffect
, that means it will run later (other effects may run after your effect). It will also force another frame to be scheduled if none is when the callback is registered, whereas
SideEffect
will only run after a composition that was going to happen anyway. Re:
scheduleFrameEndCallback
, based on the docs it looks like it does have the same behavior as the functions you’re looking for but it just doesn’t use a suspend function probably to reduce overhead when not needed. As always, you can easily turn a callback into a suspend function with
suspendCancellableCoroutine
.