From 140784ea4c4418b5f926c6a207f0c8a53c0a0787 Mon Sep 17 00:00:00 2001 From: Aditya Sharat Date: Tue, 2 Apr 2024 15:49:34 -0700 Subject: [PATCH] Ensures that the lifecycle listener release is the last to be invoked Summary: Ensures that the lifecycle listener release is the last to be invoked Differential Revision: D55653563 fbshipit-source-id: ad27cfd4fa5727395dc62f29a51ae12ec53e96d3 --- .../main/java/com/facebook/litho/NestedLithoPrimitive.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/litho-core/src/main/java/com/facebook/litho/NestedLithoPrimitive.kt b/litho-core/src/main/java/com/facebook/litho/NestedLithoPrimitive.kt index 2948df54c63..79a8e326724 100644 --- a/litho-core/src/main/java/com/facebook/litho/NestedLithoPrimitive.kt +++ b/litho-core/src/main/java/com/facebook/litho/NestedLithoPrimitive.kt @@ -115,6 +115,11 @@ fun NestedLithoPrimitive( contentAllocator = ViewAllocator { LithoRenderTreeView(it) }, ) { + // the litho lifecycle listener release callback should be the last binder to be unbound + withDescription("lifecycle-provider-release") { + bind(nestedTreeId.id) { _ -> onUnbind { lifecycleProvider.release() } } + } + // binder to clean up the content before returning it to the pool withDescription("final-unmount") { bind(nestedTreeId.id) { content -> @@ -125,10 +130,6 @@ fun NestedLithoPrimitive( } } - withDescription("lifecycle-provider-release") { - bind(nestedTreeId.id) { _ -> onUnbind { lifecycleProvider.release() } } - } - // binder to bind the layout state with the Litho Render Tree View withDescription("litho-tree") { bindWithLayoutData { content, layoutState ->