withFlippingParameters
inline suspend fun <T> withFlippingParameters(vararg parameters: Pair<String, Any>, crossinline block: suspend () -> T): T(source)
Execute a block with additional parameters merged into the current context.
If no context exists in the current coroutine scope, creates a new one with the given parameters. If a context exists, merges the new parameters (new values override existing ones).
Example:
withFlippingContext(FlippingExecutionContext(ContextKeys.USER_ID to "123", "tier" to "free")) {
// userId=123, tier=free
withFlippingParameters("tier" to "premium", ContextKeys.REGION to "EU") {
// userId=123, tier=premium, region=EU (merged)
}
// userId=123, tier=free (restored)
}Content copied to clipboard
Return
The result of the block
Parameters
parameters
The parameters to add/override
block
The suspending block to execute