Skip to content

Commit

Permalink
Remove isInitialRun logic (not needed anymore).
Browse files Browse the repository at this point in the history
  • Loading branch information
Laimiux committed Jan 22, 2024
1 parent 8681b24 commit 634c300
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions formula/src/main/java/com/instacart/formula/FormulaRuntime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class FormulaRuntime<Input : Any, Output : Any>(
) : ManagerDelegate {
private val implementation = formula.implementation()
private var manager: FormulaManagerImpl<Input, *, Output>? = null
private var hasInitialFinished = false
private var emitOutput = false
private var lastOutput: Output? = null

Expand Down Expand Up @@ -69,8 +68,7 @@ class FormulaRuntime<Input : Any, Output : Any>(
)
run()

hasInitialFinished = true
emitOutputIfNeeded(isInitialRun = true)
emitOutputIfNeeded()
} else {
inputId += 1
run()
Expand Down Expand Up @@ -149,7 +147,7 @@ class FormulaRuntime<Input : Any, Output : Any>(
executeTransitionEffects()

if (!manager.isTerminated()) {
emitOutputIfNeeded(isInitialRun = false)
emitOutputIfNeeded()
}
} catch (e: Throwable) {
isRunning = false
Expand Down Expand Up @@ -202,13 +200,17 @@ class FormulaRuntime<Input : Any, Output : Any>(
/**
* 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))
// }
}

/**
Expand Down

0 comments on commit 634c300

Please sign in to comment.