PumpVerdict
What a pumpIn pump does after onFailure has been told about a failure — the consumer's policy, stated as the callback's return value rather than built beside it (#2829).
It decides something only for PumpFailure.ITEM. After PumpFailure.UPSTREAM the flow has already ended, so both answers mean the same thing: the pump is over.
Samples
runTest {
val ledger = mutableListOf<Int>()
// Deltas, not whole values: each one only makes sense on top of every delta before it.
val deltas = flowOf(+5, -99, +3)
val pump = deltas.pumpIn(
scope = backgroundScope,
// The ledger is now missing a step, so every later delta would be applied to the wrong total.
onFailure = { _, _ -> PumpVerdict.STOP },
name = "sample-ledger",
) { delta ->
require(delta > -10) { "this delta could not be applied" }
ledger += delta
}
pump.join()
assertEquals(listOf(5), ledger)
assertFalse(pump.isCancelled)
}Entries
End this pump now. The body is never called again, nothing further is reported, and the scope — with every sibling in it — is untouched. The pump's Job completes normally once the flow lets the stop through; a flow that catches it around emit never reaches the body again, but the pump ends only when that flow does, or when its scope is cancelled — as with take on the same flow.
Companion properties
Returns an immutable kotlin.enums.EnumEntries list containing the constants of this enum type, in the order they're declared.
Companion functions
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.