In Jetpack Compose, when something needs cleanup, ...
# feed
y
In Jetpack Compose, when something needs cleanup, the usual reflex is
DisposableEffect
. But what if the composable didn’t have to own that responsibility ? I’ve just published a short article about
RememberObserver
, a Compose API that can make some designs cleaner by letting remembered objects react to being remembered and forgotten by the composition. It’s one of those APIs that many people don’t use, even though Compose itself relies on the same idea internally. Read it here : https://open.substack.com/pub/yvesandmobile/p/rememberobserver-the-compose-api
👍🏽 1
👍 7
thank you color 2
K 1
r
Do you know if using
RememberObserver
gives any performance benefits over
DisposableEffect
? Or maybe quite the opposite?
y
DisposableEffect is essentially a thin wrapper around RememberObserver; there’s no real performance difference.
thank you color 3