-
Notifications
You must be signed in to change notification settings - Fork 0
feature gate
awekrx edited this page May 29, 2026
·
1 revision
import { featureGate } from '@dev-suite/decorators/feature-gate'
class
Enable/disable class usage behind a runtime feature flag.
- Repeated flag checks in every public method
- Forked class implementations for on/off flows
class NewCheckoutFlow {
start(cartId: string) {
if (!flags.isEnabled('checkout.v2')) {
throw new Error('Feature disabled');
}
return this.orchestrator.start(cartId);
}
}import { featureGate } from '@dev-suite/decorators/feature-gate';
@featureGate({
isEnabled: () => flags.isEnabled('checkout.v2'),
featureName: 'checkout.v2',
})
class NewCheckoutFlow {
start(cartId: string) {
return this.orchestrator.start(cartId);
}
}- Gate policy is declared once at class level
- Business methods stay free from feature-toggle boilerplate
class AdvancedScoringEngine {
score(input: ScoreInput) {
if (!config.features.advancedScoring) {
throw new Error('advanced scoring disabled');
}
return this.compute(input);
}
}import { featureGate } from '@dev-suite/decorators/feature-gate';
@featureGate({ isEnabled: () => config.features.advancedScoring })
class AdvancedScoringEngine {
score(input: ScoreInput) {
return this.compute(input);
}
}- Consistent feature-gating model across multiple classes
- Easier migration when flags are removed later