whenEnabled
inline suspend fun FF4k.whenEnabled(featureId: String, executionContext: FlippingExecutionContext? = null, block: () -> Unit)(source)
Execute a block with side effects if the feature is enabled.
Returns Unit, useful for side-effect operations where no return value is needed. This is semantically clearer than ifEnabled when the block result is not used.
Example:
ff4k.whenEnabled("logging") {
logger.info("Feature is active")
}
// With execution context
ff4k.whenEnabled("analytics", context) {
trackEvent("page_view", userId)
}Content copied to clipboard
Parameters
featureId
the unique identifier of the feature to check
executionContext
optional explicit context for strategy evaluation
block
the side-effect block to execute if the feature is enabled