ObservableFeatureFlagManagerMixin

A supplement to ObservableMixinFeatureFlagManager that allows extension via ObservableFeatureFlagManagerMixin.valuesOfOrNull.

Implementations of this interface can opt to handle 1 or more FeatureFlag types. For example, if we want to add a mixin that supports JSON, we could do so with the following code.

class JsonFeatureFlagMixin : ObservableFeatureFlagMixin {

override suspend fun <T : FeatureFlagOption> valuesOrNull(
flag: FeatureFlag<T>,
store: ObservableFeatureFlagDataStore,
): T? = when (flag) {
is SomeJsonFeatureFlag<T> -> store.stringFlow(flag.key).map { decodeJson(it) }
else -> null
}

abstract fun <T : FeatureFlagOption> decodeJson(flag: FeatureFlag<T>): T
}

Functions

Link copied to clipboard
abstract fun <T : Any> currentValueOfOrNull(flag: FeatureFlag<T>, store: FeatureFlagDataStore): T?

Get the current value for flag as T from store. This function will return null if this FeatureFlagManagerMixin does not handle flag.

Link copied to clipboard
abstract fun <T : Any> valuesOfOrNull(flag: FeatureFlag<T>, store: ObservableFeatureFlagDataStore): Flow<T>?

Observes values for flag as Flow from store. This function will return null if this ObservableFeatureFlagManagerMixin does not handle flag.