feat: plug in bubbling

This commit is contained in:
Jonathan Kelley committed 2022-01-03 02:06:42 -05:00
1 parent a95dead76d
commit d84fc05386
10 files changed
+579 -522

No files matched your search

+3 -5
View File
@@ -6,14 +6,12 @@
use crate::{
innerlude::{Element, Properties, Scope, ScopeId, ScopeState},
lazynodes::LazyNodes,
Component,
AnyEvent, Component,
};
use bumpalo::{boxed::Box as BumpBox, Bump};
use std::{
any::Any,
cell::{Cell, RefCell},
fmt::{Arguments, Debug, Formatter},
sync::Arc,
};
/// A composable "VirtualNode" to declare a User Interface in the Dioxus VirtualDOM.
@@ -330,7 +328,7 @@ pub struct EventHandler<'bump> {
}
impl EventHandler<'_> {
pub fn call(&self, event: Arc<dyn Any + Send + Sync>) {
pub fn call(&self, event: AnyEvent) {
if let Some(callback) = self.callback.borrow_mut().as_mut() {
callback(event);
}
@@ -340,7 +338,7 @@ impl EventHandler<'_> {
}
}
type ListenerCallback<'bump> = BumpBox<'bump, dyn FnMut(Arc<dyn Any + Send + Sync>) + 'bump>;
type ListenerCallback<'bump> = BumpBox<'bump, dyn FnMut(AnyEvent) + 'bump>;
impl Copy for EventHandler<'_> {}
impl Clone for EventHandler<'_> {