From 557aa09ed78dd84eeb77836270f0db413337fe2e Mon Sep 17 00:00:00 2001 From: Sven Bendel Date: Thu, 16 Nov 2023 17:29:05 +0100 Subject: [PATCH] Dispose composition of `ComposeView` when unbinding `ComposeEpoxyModel` Right now the composition of `ComposeView` in `ComposeEpoxyModel` isn't properly disposed. This leads to issues where e.g. when navigating to away from the screen where the `ComposeEpoxyModel` is rendered, and then coming back, the model isn't rendered anymore. This PR fixes this by calling `ComposeView.disposeComposition()` when unbinding the `ComposeView` from the model. --- .../src/main/java/com/airbnb/epoxy/ComposeInterop.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epoxy-compose/src/main/java/com/airbnb/epoxy/ComposeInterop.kt b/epoxy-compose/src/main/java/com/airbnb/epoxy/ComposeInterop.kt index 25877fbfc9..7d2fab9df4 100644 --- a/epoxy-compose/src/main/java/com/airbnb/epoxy/ComposeInterop.kt +++ b/epoxy-compose/src/main/java/com/airbnb/epoxy/ComposeInterop.kt @@ -46,6 +46,11 @@ class ComposeEpoxyModel( view.setContent(composeFunction) } + override fun unbind(view: ComposeView) { + super.unbind(view) + view.disposeComposition() + } + override fun equals(other: Any?): Boolean { if (other === this) return true if (other !is ComposeEpoxyModel) return false