updateState

fun updateState(transform: (S) -> S): S

Updates the saga state atomically.

The transform function receives the current state and should return the new state. This operation is atomic and thread-safe.

Example

updateState { currentState ->
currentState.copy(
paymentAmount = payment.amount,
escrowCaptured = true
)
}

Return

The new state after transformation

Parameters

transform

Function that transforms current state to new state