mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 06:30:20 +00:00
downcast data with panic
This commit is contained in:
parent
3ded0f5329
commit
fc0b0f02a1
1 changed files with 7 additions and 6 deletions
|
@ -696,12 +696,13 @@ impl AttributeValue {
|
|||
/// The callback must be confined to the lifetime of the ScopeState
|
||||
pub fn listener<T: 'static>(mut callback: impl FnMut(Event<T>) + 'static) -> AttributeValue {
|
||||
AttributeValue::Listener(EventHandler::new(move |event: Event<dyn Any>| {
|
||||
if let Ok(data) = event.data.downcast::<T>() {
|
||||
callback(Event {
|
||||
propagates: event.propagates,
|
||||
data,
|
||||
});
|
||||
}
|
||||
let data = event.data.downcast::<T>().unwrap();
|
||||
// if let Ok(data) = event.data.downcast::<T>() {
|
||||
callback(Event {
|
||||
propagates: event.propagates,
|
||||
data,
|
||||
});
|
||||
// }
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue