Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite flipper config #6

Open
osipxd opened this issue May 12, 2020 · 1 comment
Open

Composite flipper config #6

osipxd opened this issue May 12, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@osipxd
Copy link
Member

osipxd commented May 12, 2020

It would be great to have the ability to simply create complex flipper configs compositions.

We have three configs (in order of priority):

  1. debug - configured from in-app debug panel
  2. remote - values from Firebase remote config
  3. local - hardcoded default values

If value not found in debug config, it will get from remote config. If value not configured in remote config it will get from local.

Our current solution

class LocalFlipperConfig() : FlipperConfig { /*...*/ }

class RemoteFlipperConfig(localConfig: LocalFlipperConfig) : FlipperConfig { 
    override fun featureIsEnabled(feature: Feature): Boolean {
        return if (hasValue(feature.id)) ... else localConfig.featureIsEnabled(feature)
    }
}

class DebugFlipperConfig(remoteConfig: RemoteFlipperConfig) : FlipperConfig { 
    override fun featureIsEnabled(feature: Feature): Boolean {
        return if (hasValue(feature.id)) ... else remoteConfig.featureIsEnabled(feature)
    }
}

ToggleRouter.init(DebugFlipperConfig(RemoteFlipperConfig(LocalFlipperConfig())))

Desired solution

class LocalFlipperConfig() : FlipperConfig { /*...*/ }

class RemoteFlipperConfig() : FlipperConfig { /*...*/ }

class DebugFlipperConfig() : FlipperConfig { /*...*/ }

ToggleRouter.init(
    DebugFlipperConfig(), 
    RemoteFlipperConfig(), 
    LocalFlipperConfig()
)
@osipxd
Copy link
Member Author

osipxd commented May 12, 2020

One of the ways I see - add method contains to FlipperConfig. Iterate over all configs and check if it contains the desired feature.

@Fi5t Fi5t self-assigned this Jul 16, 2020
@Fi5t Fi5t added the enhancement New feature or request label Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants