With the latest release of turbine I’m seeing a be...
# squarelibraries
p
With the latest release of turbine I’m seeing a behavior change I can’t make sense of. Basically it boils down to this test case failing:
Copy code
private fun contentFlow(): Flow<Int> {
    return combine(
      flowOf(Unit),
      flowOf(2).onStart { emit(1) }
    ) { _, b ->
      b
    }.onEach { println(it) }
  }

  @Test
  fun turbineCollect() = runTest {
    contentFlow()
      .test {
        check(awaitItem() == 1)
        cancelAndIgnoreRemainingEvents()
      }
  }

  @Test
  fun regularCollect() = runTest {
    check(contentFlow().toList() == listOf(1, 2))
  }
https://github.com/cashapp/turbine/issues/112
t
I could see this as potentially a race condition and non-deterministic? combine requires an emit from both flows before running the transform. It might evaluate the second flow first and have both the 1 and then the 2 emitted before suspending for flowOf Unit to emit. This would then have combine with the 2 queued for the first time Unit emits to then only emit once