Created
December 21, 2020 11:45
-
-
Save lookashc/a3d95c8de3f049cca52ec1e1dbaabc01 to your computer and use it in GitHub Desktop.
medium-feature-toggles-gist6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class FeatureToggleCompanion<T : Any>( | |
featureToggleSet: Set<@JvmSuppressWildcards FeatureToggle<*>>, | |
associatedFeature: Feature<T> | |
) { | |
protected val toggle = featureToggleSet.first { it.feature == associatedFeature } | |
val feature = toggle.feature | |
val featureValue = toggle.value | |
protected abstract fun executeUpdate(value: T): Completable | |
fun update(value: T): Disposable = | |
executeUpdate(value) | |
.subscribeOn(Schedulers.io()) | |
.doOnComplete { toggle.value = value } | |
.subscribe({}, Timber::e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment