1

I am using ngrx in my project and I would like to include feature flagging on it, but I was checking some articles on the web and none of them mention ngrx, they used plain Angular service, guard or directive.

I was wondering if that makes sense as I did not found any article or comment mentioning it and it may not be the best solution integrate with ngrx.

My idea was to save the config of feature flags in the global store and then create specific selectors for each feature where we want to use them.

Some examples would be:

  • If we want to disable a route, check a selector in a guard.
  • If we want to disable a functionality in a component, use a specific selector to check the config property.

My question is: has anyone include feature flags with ngrx? Which are the best practices to configure it properly (if it makes sense)?

Thanks in advance!

Alejandro
  • 102
  • 9
  • 1
    This is a good architectural question, but does not belong to stackoverflow since SO aims to solve concrete problems and not to propose opinonated ansewers. In my opinion though your approach is correct, but i would implement it as a feature store. I would also avoid creating selectors for each feature and use string constants instead. – kvetis Dec 23 '22 at 10:02
  • 1
    Many thanks for your comment! Sorry, I did not know that it is not the proper site... as I read some questions like that one.. Regarding your opinion, what do you mean about use string constants? Cause if we save the data in store we need to accessing it somehow. Thanks! – Alejandro Dec 23 '22 at 11:03
  • 2
    I would use following config and a parametrized selector: `interface FeatureFlagConfig { [flag: string]: boolean } function isEnabledSelector(featureFlag: string) {}` If the features are not gonna change much: interface FeatureFlagConfig { ff1: boolean, ff2: boolean } function isEnabledSelector(featureFlag: keyof FeatureFlagConfig) {} – kvetis Dec 23 '22 at 12:02
  • 1
    I am fully agree with you response, I got it, thanks for the clarification! – Alejandro Dec 23 '22 at 13:17
  • LaunchDarkly: https://learn.launchdarkly.com/demo/?utm_source=google&utm_medium=cpc&utm_campaign=brand&utm_content=demo&utm_source=google&utm_term=launchdarkly&utm_content==123821076857-554432117689&_bt=554432117689&_bm=e&_bn=g&gclid=CjwKCAiAzKqdBhAnEiwAePEjkjsvNru2zohabA1PO_A16oNSs6dSLAjPAG8hMzaVwTRXbYJwp8as9BoCTVAQAvD_BwE – Michael Kang Dec 28 '22 at 04:37

0 Answers0