From 1becdf76596972eed521535ae771ddc051fe4e9e Mon Sep 17 00:00:00 2001 From: Laimonas Turauskas Date: Tue, 28 Nov 2023 14:36:06 -0800 Subject: [PATCH] Remove FragmentFlowState activeKeys and visibleKeys. (#312) --- CHANGELOG.md | 1 + .../instacart/formula/android/FragmentFlowState.kt | 14 +++----------- .../android/internal/FragmentFlowRenderView.kt | 8 ++++---- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3b2863..67731e67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **Breaking**: Remove `Integration` and `FragmentContract` - **Breaking**: Remove `Stream`, `StreamBuilder` and `StreamFormula` - **Breaking**: Rewrite internals of formula action handling to enable inline re-evaluation. Lots of changes, can review them in https://github.com/instacart/formula/pull/301 +- **Breaking**: Remove `FragmentFlowState.activeKeys` and `FragmentFlowState.visibleKeys` ## [0.7.1] - June 28, 2022 - **Breaking**: Rename `FragmentBindingBuilder` to `FragmentStoreBuilder` diff --git a/formula-android/src/main/java/com/instacart/formula/android/FragmentFlowState.kt b/formula-android/src/main/java/com/instacart/formula/android/FragmentFlowState.kt index 985bf7d5..30c7cb84 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/FragmentFlowState.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/FragmentFlowState.kt @@ -1,10 +1,10 @@ package com.instacart.formula.android /** - * Represents currently [activeKeys] and their [states]. + * Represents currently [activeIds] and their [states]. * - * @param activeKeys Fragment contracts that are running their state management. - * @param visibleKeys Fragment contracts that are currently visible to the user. + * @param activeIds Fragment contracts that are running their state management. + * @param visibleIds Fragment contracts that are currently visible to the user. * @param states Last emitted state of each active [FragmentKey]. */ data class FragmentFlowState( @@ -13,13 +13,5 @@ data class FragmentFlowState( val features: Map = emptyMap(), val states: Map = emptyMap() ) { - @Deprecated("use activeIds") - val activeKeys: List - get() = activeIds.map { it.key } - - @Deprecated("use visibleIds") - val visibleKeys: List - get() = visibleIds.map { it.key } - fun visibleState() = visibleIds.lastOrNull()?.let { states[it] } } diff --git a/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentFlowRenderView.kt b/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentFlowRenderView.kt index fb5a3ede..30fe8eee 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentFlowRenderView.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/internal/FragmentFlowRenderView.kt @@ -35,7 +35,7 @@ internal class FragmentFlowRenderView( private val onLifecycleEvent: (FragmentLifecycleEvent) -> Unit, private val onLifecycleState: (FragmentId, Lifecycle.State) -> Unit, private val onFragmentViewStateChanged: (FragmentId, isVisible: Boolean) -> Unit -) : RenderView { +) { private var fragmentState: FragmentFlowState? = null private val visibleFragments: LinkedList = LinkedList() @@ -119,9 +119,9 @@ internal class FragmentFlowRenderView( activity.supportFragmentManager.registerFragmentLifecycleCallbacks(callback, false) } - override val render: Renderer = Renderer { - fragmentState = it - updateVisibleFragments(it) + fun render(state: FragmentFlowState) { + fragmentState = state + updateVisibleFragments(state) } fun onBackPressed(): Boolean {