diff --git a/src/dom.rs b/src/dom.rs index 86c52e2..b770f8c 100644 --- a/src/dom.rs +++ b/src/dom.rs @@ -1,6 +1,5 @@ use std::pin::Pin; use std::convert::AsRef; -use std::marker::PhantomData; use std::future::Future; use std::task::{Context, Poll}; @@ -21,10 +20,9 @@ use crate::operations::{for_each, spawn_future}; use crate::utils::{EventListener, on, on_preventable, ValueDiscard, FnDiscard}; -pub struct RefFn where B: ?Sized { +pub struct RefFn where B: ?Sized, C: Fn(&A) -> &B { value: A, callback: C, - return_value: PhantomData, } impl RefFn where B: ?Sized, C: Fn(&A) -> &B { @@ -33,7 +31,6 @@ impl RefFn where B: ?Sized, C: Fn(&A) -> &B { Self { value, callback, - return_value: PhantomData, } } @@ -423,6 +420,15 @@ impl DomBuilder { self } + // TODO add this to the StylesheetBuilder and ClassBuilder too + #[inline] + pub fn global_event_preventable(mut self, listener: F) -> Self + where T: StaticEvent, + F: FnMut(T) + 'static { + self._event_preventable(bindings::window_event_target(), listener); + self + } + #[inline] pub fn future(mut self, future: F) -> Self where F: Future + 'static { self.callbacks.after_remove(DiscardOnDrop::leak(spawn_future(future)));