Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@saqib-github-commits
Created May 17, 2023 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqib-github-commits/098c740c5824955ff87edb3633d78537 to your computer and use it in GitHub Desktop.
Save saqib-github-commits/098c740c5824955ff87edb3633d78537 to your computer and use it in GitHub Desktop.
private class DisposableEffectImpl(
private val effect: DisposableEffectScope.() -> DisposableEffectResult
) : RememberObserver {
private var onDispose: DisposableEffectResult? = null
override fun onRemembered() {
onDispose = InternalDisposableEffectScope.effect()
}
override fun onForgotten() {
onDispose?.dispose()
onDispose = null
}
override fun onAbandoned() {
// Nothing to do as [onRemembered] was not called.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment