Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 749 Bytes

feature-flags.md

File metadata and controls

34 lines (27 loc) · 749 Bytes

Feature Flags

We define features using enums, and provide a default value.

enum class Feature(
    val enabled: Boolean,
    val remoteConfigKey: String = ""
) {
  SecureCall(false, "secure_call"),
  Telemedicine(true, "telemedicine_enabled")
}

We check if a feature is enabled or not, using Features class. Since this class is part of Dagger graph we can inject it.

fun call() {
	if (features.isEnabled(SecureCall))) {
		// Handle code
	}
}

Overriding this value in tests is very simple.

@Test
fun `the feature is overriden in this test`() {
  Features.overrides[Feature.SecureCall] = true
}

You can read more about this usage here