Expand description
Runtime feature flags for TUI applications
Feature flags allow you to toggle functionality at runtime, useful for:
- Gradual feature rollouts
- A/B testing
- Debug-only features
- User preferences
§Quick Start
ⓘ
use tui_dispatch::FeatureFlags;
#[derive(FeatureFlags)]
struct Features {
#[flag(default = false)]
new_search_ui: bool,
#[flag(default = true)]
vim_bindings: bool,
}
let mut features = Features::default();
assert!(!features.new_search_ui);
assert!(features.vim_bindings);
features.enable("new_search_ui");
assert!(features.new_search_ui);§Usage in Reducers
ⓘ
fn reducer(state: &mut AppState, action: Action, features: &Features) -> bool {
match action {
Action::ShowSuggestions(s) if features.new_search_ui => {
state.suggestions = s;
true
}
Action::ShowSuggestions(_) => false, // Feature disabled
// ...
}
}§Usage in Render
ⓘ
if features.new_search_ui {
render_new_search(frame, area, state);
} else {
render_legacy_search(frame, area, state);
}Structs§
- Dynamic
Features - A dynamic feature flag store for cases where compile-time flags aren’t needed
Traits§
- Feature
Flags - Trait for feature flag containers