pub fn register_event(
            &mut self,
            elem: &web_sys::HtmlElement,
            event_type: &'static str,
            mut func: impl FnMut(EventData) -> MW + 'static,
        ) -> gloo::events::EventListener {
            let w = self.worker.clone();

            let e = elem.clone();
            gloo::events::EventListener::new(elem, event_type, move |event| {
                let e = EventData {
                    elem: &e,
                    event,
                    event_type,
                };

                let val = func(e);
                let a = JsValue::from_serde(&val).unwrap_throw();

                let data = js_sys::Array::new();
                data.set(0, JsValue::null());
                data.set(1, a);

                w.borrow().post_message(&data).unwrap_throw();
            })
        }
///
/// Register a new event that will be packaged and sent to the worker thread.
///
Register a new event that will be packaged and sent to the worker thread.
Register a new event that will be packaged and sent to the worker thread .
pub fn register_event(
            &mut self,
            elem: &web_sys::HtmlElement,
            event_type: &'static str,
            mut func: impl FnMut(EventData) -> MW + 'static,
        ) -> gloo::events::EventListener {
            let w = self.worker.clone();
            let e = elem.clone();
            gloo::events::EventListener::new(elem, event_type, move |event| {
                let e = EventData {
                    elem: &e,
                    event,
                    event_type,
                };
                let val = func(e);
                let a = JsValue::from_serde(&val).unwrap_throw();
                let data = js_sys::Array::new();
                data.set(0, JsValue::null());
                data.set(1, a);
                w.borrow().post_message(&data).unwrap_throw();
            })
        }
pub fn register_event ( & mut self , elem : & web_sys :: HtmlElement , event_type : & ' static str , mut func : impl FnMut ( EventData ) -> MW + ' static , ) -> gloo :: events :: EventListener { let w = self . worker . clone ( ) ; let e = elem . clone ( ) ; gloo :: events :: EventListener :: new ( elem , event_type , move | event | { let e = EventData { elem : & e , event , event_type , } ; let val = func ( e ) ; let a = JsValue :: from_serde ( & val ) . unwrap_throw ( ) ; let data = js_sys :: Array :: new ( ) ; data . set ( 0 , JsValue :: null ( ) ) ; data . set ( 1 , a ) ; w . borrow ( ) . post_message ( & data ) . unwrap_throw ( ) ; } ) }
Register a new event that will be packaged and sent to the worker thread.
Register a new event that will be packaged and sent to the worker thread .
&mut self
elem
&web_sys::HtmlElement
event_type
&'static str
func
impl FnMut(EventData) -> MW + 'static
&mut self
elem
&web_sys::HtmlElement
event_type
&'static str
func
impl FnMut(EventData) -> MW + 'static