2

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!

4
  • 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. Commented Dec 23, 2022 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! Commented Dec 23, 2022 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) {} Commented Dec 23, 2022 at 12:02
  • 1
    I am fully agree with you response, I got it, thanks for the clarification! Commented Dec 23, 2022 at 13:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.