Are feature flag limited to booleans ?
No, feature flags are not limited to just boolean values. When I got to know about feature flag I thought the application was only to toggle features for the users.
{
"SERVICE_1":true,
"SERVICE_2":false,
....
}
But recently while working in Tekion I faced one problem where I have to derive different different behavior based on user plan for example (not related).
If you are user opt for some service by some 3rd party provider for example verification so at frontend side we have different different behavior for that, some integration want some mendatory field, some need extra field.
So I changed the implementation for our feature flag engine, previously it only support boolean value, now it support String flags, Numeric flags, JSON/Map, Percentage.
Let’s take example of JSON/Map flags now it look like.
{
"SERVICE_1":{
"ALLOWED_ENTITIES":[ ...list of entities]
},
....
}
How to consume this feature flags ?
So you can pass this config by React.context
or you can also use Redux
which internally use React.context
.
Also instead of passing config directly you can pass callbacks which is created using feature config, so they have access of config in their lexical environment.
To consume value in any component/flow, you can write common hook which will return the flag value so consumer will this hook only, otherwise they have to implement their own consuming mechanism.
So brother what is the advice ?
Feature flag is powerful design, I recommned to make your feature flag engine extendable.
Subscribe to my newsletter
Read articles from Animesh Shrivatri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by