ابرووا
شروع رایگان
☰ فهرست مستندات · وابستگی‌ها
به‌زودی. Abrova Flags به‌زودی فعال می‌شود. این صفحه توضیح می‌دهد چطور کار خواهد کرد؛ هنوز قابل استفاده نیست.
این صفحه هنوز ترجمه نشده — نسخه‌ی انگلیسی نمایش داده می‌شود. English

Flag Dependencies

Create relationships between flags. A dependent flag is only enabled when all its dependencies are met — perfect for feature chains and prerequisite logic.

به‌روزرسانی: ۵ آبان ۱۴۰۵
Flag Dependencies.

Flag dependencies let you create relationships between flags. A dependent flag is only enabled when all its dependencies are met — perfect for feature chains and prerequisite logic.

How Dependencies Work#

When a flag has dependencies, all of them are checked first. If any dependency is not met, the dependent flag is served off (enabled: false, the flag's off value) with reason PREREQUISITE_FAILED.

Upgrading from 0.1.x: enforced in every SDK.

With the 0.2.0 SDKs, dependencies apply everywhere. For client SDKs the service checks them when it evaluates for the user. The Node.js and Next.js server SDKs check them locally. SDK 0.1.x ignored dependencies.

json
{
  "dependencies": [
    { "flagKey": "dark_mode" },
    { "flagKey": "beta_features", "expectedValue": true }
  ]
}

In this example, the flag is only enabled if both dark_mode is enabled AND beta_features evaluates to true.

  • Without expectedValue, a dependency is met when that flag is served on for the user.
  • With expectedValue, it is met when the value served to the user equals it.
  • A dependency is evaluated in the same environment and for the same user as the flag itself. So a dependency with a 20% rollout is met only for the users inside that 20%.

Evaluation Order#

Dependencies are resolved recursively during evaluation:

text
Evaluating flag "premium_dark_theme":
  1. Check dependency: "dark_mode"
     → dark_mode is enabled ✓
  2. Check dependency: "beta_features"
     → beta_features is enabled ✓
     → expectedValue matches ✓
  3. All dependencies met → continue evaluation
  4. Check targeting rules, rollout, variants...
  5. Return result

In code you can see the outcome in the reason:

typescript
// Server SDK
const d = flags.getDetail('premium_dark_theme', { userId: 'user-123' }, false);
if (d.reason === 'PREREQUISITE_FAILED') {
  // dark_mode or beta_features is not met for this user
}

Use Cases#

Feature Chains

Ensure a prerequisite feature is enabled before enabling dependent features (e.g., "dark mode themes" depends on "dark mode")

Staged Rollouts

Release features in phases — Phase 2 depends on Phase 1 being enabled

Platform Requirements

A mobile-only feature depends on a "mobile_v2" platform flag

A/B Test Prerequisites

An experiment depends on the base feature being enabled first

Circular Dependency Protection.

Circular dependencies are detected when a flag is created or updated, and the change is rejected with an error. A flag cannot depend on itself, and every referenced flag must exist. At evaluation time, a dependency on a flag that no longer exists, or a chain deeper than 10 flags, counts as not met.

این صفحه مفید بود؟
گزارش مشکل