ngx-feature-toggle icon indicating copy to clipboard operation
ngx-feature-toggle copied to clipboard

NgxFeatureToggleRouteGuard with OR behavior

Open yl-endress opened this issue 2 years ago • 0 comments

I'm submitting a ... (check one with "x")

  • [ ] bug report => search github for a similar issue or PR before submitting
  • [x] feature request

Current behavior Currently, all given feature toggles must be fulfilled. I'd like to have the option if any of the feature properties is fulfilled.

Currently, the AND behavior enforces to deactivate all not required features, like the following:

export const MY_ROUTE: Route = {
  path: "my",
  canActivate: [NgxFeatureToggleRouteGuard],
  loadChildren: () => import(/* webpackChunkName: "my-chunk" */ "./../components/my/my.module").then(lazyModule => lazyModule.MyModule),
  data: {
    featureToggle: [
      "!C", "!D"
    ]
  }
};

As the list of feature toggle grows, this list must be touched again to exclude new feature-toggle (f.e. "!E"). => I suggest to support besides the AND behavior also the OR behavior

Expected behavior

I'd like to have a featureOrToggle like this:

export const MY_ROUTE: Route = {
  path: "my",
  canActivate: [NgxFeatureToggleRouteGuard],
  loadChildren: () => import(/* webpackChunkName: "my-chunk" */ "./../components/my/my.module").then(lazyModule => lazyModule.MyModule),
  data: {
    featureToggleOr: [
      "A", "B"
    ]
  }
};

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Avoid code changes in feature -> it's not mandatory to exclude further features

Please tell us about your environment:

  • Currently, we are using "ngx-feature-toggle": "11.0.0",

yl-endress avatar Mar 29 '23 09:03 yl-endress