Skip to content

Conversation

@gastonfournier
Copy link
Contributor

This creates a UI that allows a user to query an Unleash server with its client features definitions and show the compiled grammar from Yggdrasil, allowing the user to modify and play around with the grammar in real time. Yggdrasil engine runs in the browser as a WASM module, which means it only needs one call to the server to get the definitions, and then changes in the grammar can be applied without re-fetching.

This is what the UI looks like:

image

Comment on lines +32 to +37
pub fn new() -> WasmEngine {
WasmEngine {
compiled_state: CompiledState::default(),
grammars: HashMap::new(),
}
}

Check warning

Code scanning / clippy

you should consider adding a Default implementation for WasmEngine Warning

you should consider adding a Default implementation for WasmEngine
pub fn load_client_features(&mut self, features_json: &str) -> Result<JsValue, JsValue> {
let warnings = self
.load_client_features_internal(features_json)
.map_err(|err| js_error(err))?;

Check warning

Code scanning / clippy

redundant closure Warning

redundant closure
#[wasm_bindgen(js_name = "setToggleGrammar")]
pub fn set_toggle_grammar(&mut self, toggle_name: &str, grammar: &str) -> Result<(), JsValue> {
self.apply_grammar_internal(toggle_name, grammar)
.map_err(|err| js_error(err))

Check warning

Code scanning / clippy

redundant closure Warning

redundant closure

for (toggle_name, grammar) in updates {
self.apply_grammar_internal(&toggle_name, &grammar)
.map_err(|err| js_error(err))?;

Check warning

Code scanning / clippy

redundant closure Warning

redundant closure
pub fn evaluate(&self, toggle_name: &str, context_json: &str) -> Result<JsValue, JsValue> {
let evaluation = self
.evaluate_internal(toggle_name, context_json)
.map_err(|err| js_error(err))?;

Check warning

Code scanning / clippy

redundant closure Warning

redundant closure
Comment on lines +107 to +114
self.compiled_state
.iter()
.map(|(_, toggle)| ToggleDefinition {
name: toggle.name.clone(),
feature_type: toggle.feature_type.clone(),
project: toggle.project.clone(),
enabled: toggle.enabled,
})

Check warning

Code scanning / clippy

iterating on a map's values Warning

iterating on a map's values
@FredrikOseberg FredrikOseberg moved this from New to In Progress in Issues and PRs Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant