From 42d07b5942e91c14a71bffc74b521618aff63f5e Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 1 Sep 2023 13:34:39 +0100 Subject: [PATCH] Expose AndroidLifecycle for Android targets + create a helper function --- .../com/bumble/appyx/navigation/platform/LifecycleExt.kt | 6 ++++++ .../appyx/navigation/platform/PlatformLifecycleRegistry.kt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt new file mode 100644 index 000000000..f764d7cd4 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt @@ -0,0 +1,6 @@ +package com.bumble.appyx.navigation.platform + +import com.bumble.appyx.navigation.node.Node + +val Node.androidLifecycle: androidx.lifecycle.Lifecycle + get() = (lifecycle as PlatformLifecycleRegistry).androidLifecycleRegistry diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 04af120ac..70b5660ec 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -17,7 +17,7 @@ actual class PlatformLifecycleRegistry( androidx.lifecycle.LifecycleEventObserver { private var lifecycleOwner: LifecycleOwner? = androidOwner - private val androidLifecycleRegistry = LifecycleRegistry(androidOwner) + val androidLifecycleRegistry = LifecycleRegistry(androidOwner) private val managedDefaultLifecycleObservers: MutableList = ArrayList()