We[4] have a few[1] guide[2] articles[3] in our docs which might give people some ideas on how they can be used.<p>[1] <a href="https://docs.flagsmith.com/guides-and-examples/mobile-app-versioning" rel="nofollow">https://docs.flagsmith.com/guides-and-examples/mobile-app-ve...</a><p>[2] <a href="https://docs.flagsmith.com/guides-and-examples/staged-feature-rollouts" rel="nofollow">https://docs.flagsmith.com/guides-and-examples/staged-featur...</a><p>[3] <a href="https://docs.flagsmith.com/guides-and-examples/testing-push-notifications" rel="nofollow">https://docs.flagsmith.com/guides-and-examples/testing-push-...</a><p>[4] <a href="https://github.com/Flagsmith" rel="nofollow">https://github.com/Flagsmith</a>
The easiest way to do it is to create environment variables and check against them in code. This allows turning on / off functionality globally. Systems like AWS and Heroku allow toggling them without redeploying.<p>You can also create features that apply to individual users or if enterprise then to all users in the customer. This can be done by creating some boolean fields in the database (using a single feature_flags json field is recommended because then you don't have to change the schema every time a new feature flag is added.)<p>And then in code you check against the environment variable or against the user / customer before running changed functionality via a simple if statement.
The idea is that for some particular new feature/behaviour/optimization your application has, instead of just coding it, code it in a way that can be disabled easily:<p>For example, I have some projects using using redux-saga, I'll do something like:<p><pre><code> if (env.EnableSomeNewThing) {
yield fork(saga1)
}
</code></pre>
So this behavior can be enabled/disabled using an env variable instead of commenting/reverting code from Git. Of course this could also be more sophisticated: enable via configuration, enable for a sample of the users, or premium users...
I export a boolean such as `hasFeatureX` and then delete it.<p><pre><code> if (hasFeatureX) doX()
else …
</code></pre>
If it has to be more complex than that, I use a feature branch.
Check out some of the blog posts from <a href="https://launchdarkly.com/blog/" rel="nofollow">https://launchdarkly.com/blog/</a>