Merge pull request #208 from jquesada2016/207

fixes compiler recursion limit on `View::on`
This commit is contained in:
Greg Johnston 2022-12-31 19:15:28 -05:00 committed by GitHub
commit 795270447b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -544,6 +544,14 @@ impl View {
self,
event: E,
event_handler: impl FnMut(E::EventType) + 'static,
) -> Self {
self.on_impl(event, Box::new(event_handler))
}
fn on_impl<E: ev::EventDescriptor + 'static>(
self,
event: E,
event_handler: Box<dyn FnMut(E::EventType)>,
) -> Self {
cfg_if! {
if #[cfg(all(target_arch = "wasm32", feature = "web"))] {
@ -565,7 +573,7 @@ impl View {
c.children.iter().cloned().for_each(|c| {
let event_handler = event_handler.clone();
c.on(event.clone(), move |e| event_handler.borrow_mut()(e));
c.on(event.clone(), Box::new(move |e| event_handler.borrow_mut()(e)));
});
}
Self::CoreComponent(c) => match c {