FeatureFlip Module
A Kotlin Multiplatform library for managing feature flags (feature toggles) with a built-in UI for toggling and managing features at runtime.
[Placeholder: Insert screenshot of FeatureFlip UI. Use a device frame if relevant.]
Overview
FeatureFlip enables runtime control of feature flags for development, QA, and experimentation. It supports both local and remote features, persistent state, and a ready-to-use Compose UI.
Features
- Local and remote feature flags
- Persistent state with DataStore (Android/iOS)
- Built-in Compose UI: search, filter, toggle, tri-state controls
- Type-safe API
- Multiplatform support
Installation
Add to your build.gradle.kts:
Integration Example
Add FeatureFlip to your DevView modules list:
Quick Start
Defining Features
val darkMode = Feature.LocalFeature(
name = "dark_mode",
description = "Enable dark theme",
isEnabled = false
)
val newCheckout = Feature.RemoteFeature(
name = "new_checkout_flow",
description = "Enable the redesigned checkout experience",
defaultRemoteValue = true,
state = FeatureState.REMOTE
)
Using the UI
CompositionLocalProvider(LocalFeatures provides features) {
FeatureFlipScreen(onStateChange = { featureName, newState ->
// Handle state change
})
}
Usage
- Use
FeatureHandlerto manage features programmatically. - Use
FeatureFlipScreenfor a ready-made UI. - Features are persisted using DataStore.
Customisation
[Placeholder: Guide for customising FeatureFlip UI and behaviour. This section will be expanded in future updates.]
Advanced Usage
[Placeholder: Advanced scenarios such as remote config integration, tri-state features, and platform-specific customisation.]
Best Practices
- Use descriptive names and add descriptions.
- Start with REMOTE for remote features, override only for testing.
- Persist state for reliability.
- Monitor overrides for QA.
Troubleshooting / FAQ
- Why isn't my feature state persisting?
- Ensure you use
FeatureHandlerand DataStore correctly. - Check DataStore permissions and initialisation on both Android and iOS.
- How do I reset a remote feature to remote config?
- Set its state to
FeatureState.REMOTE. - Can I use this on iOS?
- Yes, DataStore is supported on both Android and iOS. Ensure platform-specific initialisation is correct.
- Feature UI not updating?
- Confirm you are using Compose state correctly and updating the feature list.
- Integration issues?
- Verify module is included in your DevView modules list and dependencies are present.
Related Modules
- Analytics: Monitor feature usage and events.
- NetworkMock: Combine with feature flags for advanced testing.
- Creating Custom Modules
API Reference
API reference is available via Dokka or in your IDE.