From 634c30015c4abc04443746decc741d954218244a Mon Sep 17 00:00:00 2001 From: Laimonas Turauskas Date: Mon, 22 Jan 2024 11:14:37 -0500 Subject: [PATCH] Remove isInitialRun logic (not needed anymore). --- .../com/instacart/formula/FormulaRuntime.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/formula/src/main/java/com/instacart/formula/FormulaRuntime.kt b/formula/src/main/java/com/instacart/formula/FormulaRuntime.kt index 1856b007..73b47bd6 100644 --- a/formula/src/main/java/com/instacart/formula/FormulaRuntime.kt +++ b/formula/src/main/java/com/instacart/formula/FormulaRuntime.kt @@ -19,7 +19,6 @@ class FormulaRuntime( ) : ManagerDelegate { private val implementation = formula.implementation() private var manager: FormulaManagerImpl? = null - private var hasInitialFinished = false private var emitOutput = false private var lastOutput: Output? = null @@ -69,8 +68,7 @@ class FormulaRuntime( ) run() - hasInitialFinished = true - emitOutputIfNeeded(isInitialRun = true) + emitOutputIfNeeded() } else { inputId += 1 run() @@ -149,7 +147,7 @@ class FormulaRuntime( executeTransitionEffects() if (!manager.isTerminated()) { - emitOutputIfNeeded(isInitialRun = false) + emitOutputIfNeeded() } } catch (e: Throwable) { isRunning = false @@ -202,13 +200,17 @@ class FormulaRuntime( /** * Emits output to the formula subscriber. */ - private fun emitOutputIfNeeded(isInitialRun: Boolean) { - if (isInitialRun) { - lastOutput?.let(onOutput) - } else if (hasInitialFinished && emitOutput) { + private fun emitOutputIfNeeded() { + if (emitOutput) { emitOutput = false onOutput(checkNotNull(lastOutput)) } +// if (isInitialRun) { +// lastOutput?.let(onOutput) +// } else if (hasInitialFinished && emitOutput) { +// emitOutput = false +// onOutput(checkNotNull(lastOutput)) +// } } /**