Toggle

interface Toggle

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class DefaultValue(val defaultValue: Boolean)

This annotation is required. It specifies the default value of the feature flag when it's not remotely defined

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class Experiment

This annotation should be used in feature flags that related to experimentation. It will make the feature flag to set the default variant if isEnabled is called BEFORE any variant has been allocated. It will make the feature flag to consider the target variants during the isEnabled evaluation.

Link copied to clipboard
data class FeatureName(val parentName: String?, val name: String)

The feature name the name of the feature parentName the name of the parent feature, or null if the feature has no parent (root feature)

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class InternalAlwaysEnabled

This annotation is optional. It will make the feature flag ALWAYS enabled for internal builds

Link copied to clipboard
data class State(val remoteEnableState: Boolean? = null, val enable: Boolean = false, val minSupportedVersion: Int? = null, val rollout: List<Double>? = null, val rolloutThreshold: Double? = null, val targets: List<Toggle.State.Target> = emptyList(), val metadataInfo: String? = null)

This represents the state of a Toggle

Link copied to clipboard
interface Store

Functions

Link copied to clipboard
Link copied to clipboard

The usage of this API is only useful for internal/dev settings/features If you find yourself having to call this method in production code, then YOU'RE DOING SOMETHING WRONG The raw state is the stored state. isEnabled method takes the raw state and computes whether the feature should be enabled or disabled. eg. by factoring in State.minSupportedVersion amongst others.

Link copied to clipboard
abstract fun isEnabled(): Boolean

This is the method that SHALL be called to get whether a feature is enabled or not. DO NOT USE getRawStoredState for that

Link copied to clipboard
abstract fun setRawStoredState(state: Toggle.State)

The usage of this API is only useful for internal/dev settings/features If you find yourself having to call this method in production code, then YOU'RE DOING SOMETHING WRONG