Fix toggle_all panic

This commit is contained in:
Greg Johnston 2022-11-10 21:43:40 -05:00
parent e3c1291942
commit 01807ea514
2 changed files with 8 additions and 2 deletions

View file

@ -211,7 +211,7 @@ pub fn TodoMVC(cx: Scope) -> Element {
>
<input id="toggle-all" class="toggle-all" type="checkbox"
prop:checked={move || todos.with(|t| t.remaining() > 0)}
on:input=move |_| set_todos.update(|t| t.toggle_all())
on:input=move |_| todos.with(|t| t.toggle_all())
/>
<label for="toggle-all">"Mark all as complete"</label>
<ul class="todo-list">

View file

@ -644,7 +644,13 @@ impl SignalId {
}
}
}?;
let value = value.borrow();
let value = value.try_borrow().unwrap_or_else(|e| {
debug_warn!(
"Signal::try_with_no_subscription failed on Signal<{}>. It seems you're trying to read the value of a signal within an effect caused by updating the signal.",
std::any::type_name::<T>()
);
panic!("{e}");
});
let value = value
.downcast_ref::<T>()
.ok_or_else(|| SignalError::Type(std::any::type_name::<T>()))?;