ifEnabled
inline suspend fun <T> FF4k.ifEnabled(featureId: String, executionContext: FlippingExecutionContext? = null, block: () -> T): T?(source)
Execute a block if the feature is enabled.
Returns the block result if the feature is enabled, null otherwise. Useful for conditional execution with a result value.
Example:
val result = ff4k.ifEnabled("new-algorithm") {
runNewAlgorithm()
}
// With execution context
val result = ff4k.ifEnabled("personalized-ui", context) {
buildPersonalizedUI(userId)
}Content copied to clipboard
Return
the block result if the feature is enabled, null otherwise
Parameters
T
the return type of the block
featureId
the unique identifier of the feature to check
executionContext
optional explicit context for strategy evaluation
block
the block to execute if the feature is enabled