• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
CLOSE
launchdarkly.com

EDIT ON GITHUB

Flag prerequisites

Read time: 1 minute
Last edited: Feb 12, 2020

Overview

This topic explains how to use feature flag prerequisites to enable or disable features based on different states.

Understanding flag prerequisite relationships

Prerequisites allow you to control feature dependencies in LaunchDarkly. You can make flags depend on other flags being enabled to take effect themselves, making them prerequisites to enable a feature.

For example, you have two flags that control read and write access to an API: "Alternate sort order" and "API Migration." If you do not have read access to the API, you cannot see it, so you cannot write to it. You can set up "Alternate sort order" as a prerequisite before "API Migration" is evaluated for a user by making sure "Alternate sort order" is On and the user is seeing the true variation.

Manage prerequisites in the feature flag's Targeting tab:

The flag's Targeting tab.
The flag's Targeting tab.

In the screenshot above, the "Alternate sort order" flag is a prerequisite of the "API Migration" flag. To meet a prerequisite, the prerequisite flag must be On, and the user must receive the variation you specify.

In this example, if a user receives the false variation of the "Alternate sort order" flag, they will not be able to write to the API. The "API Migration" flag will not evaluate for them, because the prerequisites are not met.

Don't worry about circular dependencies
LaunchDarkly automatically prevents you from saving changes that would introduce circular dependencies between prerequisites. For example, you cannot make Flag A a prerequisite of Flag B and also make Flag B a prerequisite of Flag A.
Deleting flags with prerequisites
You cannot remove a flag that is a prerequisite for other flags. You must remove the dependency before you can delete the prerequisite flag.