Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created August 9, 2025 02:25
Show Gist options
  • Select an option

  • Save skydoves/b02a1371ad752bdc7d31de790664f39c to your computer and use it in GitHub Desktop.

Select an option

Save skydoves/b02a1371ad752bdc7d31de790664f39c to your computer and use it in GitHub Desktop.
RetainedEffectImpl
private class RetainedEffectImpl(
private val effect: RetainedEffectScope.() -> RetainedEffectResult
) : RetainObserver {
private var onRetire: RetainedEffectResult? = null
override fun onRetained() {
onRetire = InternalRetainedEffectScope.effect()
}
override fun onRetired() {
onRetire?.retire()
onRetire = null
}
override fun onEnteredComposition() {
// Do nothing.
}
override fun onExitedComposition() {
// Do nothing.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment