Test representation validity in realization effect

This commit is contained in:
Aaron Fenyes 2024-11-01 20:40:25 -07:00
parent e12f4332fe
commit 327a1267d5

View File

@ -187,15 +187,15 @@ pub fn AddRemove() -> View {
} }
); );
let rep = create_signal(0.0); let rep = create_signal(0.0);
let rep_valid = create_signal(false);
let active = create_signal(true); let active = create_signal(true);
state.assembly.insert_constraint(Constraint { state.assembly.insert_constraint(Constraint {
args: args, args: args,
rep: rep, rep: rep,
rep_text: create_signal(String::new()), rep_text: create_signal(String::new()),
rep_valid: create_signal(false), rep_valid: rep_valid,
active: active, active: active,
}); });
state.assembly.realize();
state.selection.update(|sel| sel.clear()); state.selection.update(|sel| sel.clear());
/* DEBUG */ /* DEBUG */
@ -213,15 +213,14 @@ pub fn AddRemove() -> View {
} }
}); });
// update the realization when the constraint is activated, // update the realization when the constraint becomes active
// or edited while active // and valid, or is edited while active and valid
create_effect(move || { create_effect(move || {
console::log_1(&JsValue::from(
format!("Constraint ({}, {}) updated", args.0, args.1)
));
rep.track(); rep.track();
console::log_2( if active.get() && rep_valid.get() {
&JsValue::from("Lorentz product updated to"),
&JsValue::from(rep.get_untracked())
);
if active.get() {
state.assembly.realize(); state.assembly.realize();
} }
}); });