Skip to content

Instantly share code, notes, and snippets.

@mizrael
Created March 6, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizrael/7e785a79747fd39b390a7d4e13b75f71 to your computer and use it in GitHub Desktop.
Save mizrael/7e785a79747fd39b390a7d4e13b75f71 to your computer and use it in GitHub Desktop.
Feature Gating - check the gates
export class Foo implements IFoo{
constructor(private readonly barStrategy:()=>void){}
public bar(){
this.barStrategy();
}
};
// composition root
const featureService:IFeatureService = new FeatureService(),
strategy1 = ():void =>{ /*...strategy 1...*/ },
strategy2 = ():void =>{ /*...strategy 2...*/ },
barStrategy:()=>void = featureService.isEnabled("feature-x") ? strategy1 : strategy2,
foo:IFoo = new Foo(barStrategy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment