Search code examples
togglz

How do I disable the enabled feature when I enable a new feature in togglz?


Say I have features A, B, C, and A is enabled by default. B and C disabled.

When I enable B I want to disable A: only one feature should be enabled at a time.


Solution

  • You'll need to implement a custom version of the StateRepository interface. Information on this can be found on the togglz documentation

    Next override the setFeatureState(...) function for the required functionality.

    • Disable active features (query via FeatureManager or Feature enum - you may need to implement custom versions of these classes for the desired functionality)
    • Enable the feature being set.