From f5014598ba9f2b59ca17ec05ea2e3cdab83846c2 Mon Sep 17 00:00:00 2001 From: Lachlan McKee Date: Mon, 18 Nov 2024 16:00:09 +0000 Subject: [PATCH 1/3] Introduced global plugins, added GlobalNodeLifecycleAware --- CHANGELOG.md | 1 + libraries/core/src/main/kotlin/com/bumble/appyx/Appyx.kt | 6 ++++++ .../core/src/main/kotlin/com/bumble/appyx/core/node/Node.kt | 5 ++++- .../src/main/kotlin/com/bumble/appyx/core/plugin/Plugins.kt | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e8072a67..686231455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#705](https://github.com/bumble-tech/appyx/pull/705) – **Fixed**: ChildAware extension functions now allow Any type as a parameter - [#716](https://github.com/bumble-tech/appyx/pull/716) – **Updated**: Kotlin (2.0.20), Compose Compiler (now implicit from Kotlin), Coroutines (1.9.0-RC.2), AGP (8.5.2), numerous Androidx libs +- [#718](https://github.com/bumble-tech/appyx/pull/718) – **Added**: Introduced global plugins for all nodes and added [GlobalNodeLifecycleAware] which is contains the node in the callback. --- diff --git a/libraries/core/src/main/kotlin/com/bumble/appyx/Appyx.kt b/libraries/core/src/main/kotlin/com/bumble/appyx/Appyx.kt index 51a57902e..3102d99a5 100644 --- a/libraries/core/src/main/kotlin/com/bumble/appyx/Appyx.kt +++ b/libraries/core/src/main/kotlin/com/bumble/appyx/Appyx.kt @@ -1,12 +1,18 @@ package com.bumble.appyx import com.bumble.appyx.core.children.ChildEntry +import com.bumble.appyx.core.plugin.Plugin object Appyx { var exceptionHandler: ((Exception) -> Unit)? = null var defaultChildKeepMode: ChildEntry.KeepMode = ChildEntry.KeepMode.KEEP + /** + * Plugins that are applied to all Nodes. + */ + var globalPlugins: List = emptyList() + fun reportException(exception: Exception) { val handler = exceptionHandler if (handler != null) { diff --git a/libraries/core/src/main/kotlin/com/bumble/appyx/core/node/Node.kt b/libraries/core/src/main/kotlin/com/bumble/appyx/core/node/Node.kt index 2ffcceef7..7c5b19e62 100644 --- a/libraries/core/src/main/kotlin/com/bumble/appyx/core/node/Node.kt +++ b/libraries/core/src/main/kotlin/com/bumble/appyx/core/node/Node.kt @@ -27,6 +27,7 @@ import com.bumble.appyx.core.modality.AncestryInfo import com.bumble.appyx.core.modality.BuildContext import com.bumble.appyx.core.plugin.BackPressHandler import com.bumble.appyx.core.plugin.Destroyable +import com.bumble.appyx.core.plugin.GlobalNodeLifecycleAware import com.bumble.appyx.core.plugin.NodeLifecycleAware import com.bumble.appyx.core.plugin.NodeReadyObserver import com.bumble.appyx.core.plugin.Plugin @@ -57,7 +58,7 @@ open class Node @VisibleForTesting internal constructor( @Suppress("LeakingThis") // Implemented in the same way as in androidx.Fragment private val nodeLifecycle = NodeLifecycleImpl(this) - val plugins: List = plugins + listOfNotNull(this as? Plugin) + val plugins: List = plugins + Appyx.globalPlugins + listOfNotNull(this as? Plugin) val ancestryInfo: AncestryInfo = buildContext.ancestryInfo @@ -115,6 +116,7 @@ open class Node @VisibleForTesting internal constructor( updateLifecycleState(Lifecycle.State.CREATED) plugins>().forEach { it.init(this) } plugins().forEach { it.onCreate(lifecycle) } + plugins().forEach { it.onCreate(this, lifecycle) } } @Composable @@ -179,6 +181,7 @@ open class Node @VisibleForTesting internal constructor( retainedInstanceStore.clearStore(id) } plugins().forEach { it.destroy() } + plugins().forEach { it.onDestroy(this) } } } diff --git a/libraries/core/src/main/kotlin/com/bumble/appyx/core/plugin/Plugins.kt b/libraries/core/src/main/kotlin/com/bumble/appyx/core/plugin/Plugins.kt index c4eaa4ed7..c0176bd26 100644 --- a/libraries/core/src/main/kotlin/com/bumble/appyx/core/plugin/Plugins.kt +++ b/libraries/core/src/main/kotlin/com/bumble/appyx/core/plugin/Plugins.kt @@ -23,6 +23,11 @@ interface NodeLifecycleAware : Plugin { fun onCreate(lifecycle: Lifecycle) {} } +interface GlobalNodeLifecycleAware : Plugin { + fun onCreate(node: Node, lifecycle: Lifecycle) {} + fun onDestroy(node: Node) {} +} + interface UpNavigationHandler : Plugin { fun handleUpNavigation(): Boolean = false } From 7365ed2b8fa2fe46bc368f3f52fd80c6a9778a8f Mon Sep 17 00:00:00 2001 From: Lachlan McKee Date: Mon, 18 Nov 2024 16:00:24 +0000 Subject: [PATCH 2/3] Fixed github actions issues --- .github/workflows/build_1.x.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_1.x.yml b/.github/workflows/build_1.x.yml index 744891b4b..dac1ba78a 100644 --- a/.github/workflows/build_1.x.yml +++ b/.github/workflows/build_1.x.yml @@ -125,7 +125,7 @@ jobs: ./gradlew connectedCheck - name: Upload failed instrumentation artifacts if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: instrumentation-failures path: | From 65bd959c48112e73e2f79b0e27f9c07903283148 Mon Sep 17 00:00:00 2001 From: Lachlan McKee Date: Mon, 18 Nov 2024 16:01:18 +0000 Subject: [PATCH 3/3] Release 1.5.1 --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 686231455..4effcb722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,14 @@ ## Pending changes +## 1.5.1 + - [#705](https://github.com/bumble-tech/appyx/pull/705) – **Fixed**: ChildAware extension functions now allow Any type as a parameter - [#716](https://github.com/bumble-tech/appyx/pull/716) – **Updated**: Kotlin (2.0.20), Compose Compiler (now implicit from Kotlin), Coroutines (1.9.0-RC.2), AGP (8.5.2), numerous Androidx libs - [#718](https://github.com/bumble-tech/appyx/pull/718) – **Added**: Introduced global plugins for all nodes and added [GlobalNodeLifecycleAware] which is contains the node in the callback. +
18 Nov 2024
+ --- ## 1.5.0 diff --git a/gradle.properties b/gradle.properties index 924b999b2..d7a6d488d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.caching=true org.gradle.parallel=true android.useAndroidX=true kotlin.code.style=official -library.version=1.5.0 +library.version=1.5.1