fn react_on_message(self, mut handler: impl FnMut() + 'static) {
        let is_queued = self.is_queued.clone();
        let closure: Closure<dyn FnMut(JsValue)> = Closure::wrap(Box::new(move |_| {
            handler();

            // Unblock the queue.
            *is_queued.borrow_mut() = false;
        }));
        self.port
            .set_onmessage(Some(closure.as_ref().unchecked_ref()));

        // Leak the closure so that the app lives on for 'static lifetimes.
        closure.forget();
    }
/// Invokes the handler, when it receives a message.
Invokes the handler, when it receives a message.
Invokes the handler when it receives a message .
fn react_on_message(self, mut handler: impl FnMut() + 'static) {
        let is_queued = self.is_queued.clone();
        let closure: Closure<dyn FnMut(JsValue)> = Closure::wrap(Box::new(move |_| {
            handler();
            // Unblock the queue.
            *is_queued.borrow_mut() = false;
        }));
        self.port
            .set_onmessage(Some(closure.as_ref().unchecked_ref()));
        // Leak the closure so that the app lives on for 'static lifetimes.
        closure.forget();
    }
fn react_on_message ( self , mut handler : impl FnMut ( ) + ' static ) { let is_queued = self . is_queued . clone ( ) ; let closure : Closure < dyn FnMut ( JsValue ) > = Closure :: wrap ( Box :: new ( move | _ | { handler ( ) ; // Unblock the queue. * is_queued . borrow_mut ( ) = false ; } ) ) ; self . port . set_onmessage ( Some ( closure . as_ref ( ) . unchecked_ref ( ) ) ) ; // Leak the closure so that the app lives on for 'static lifetimes. closure . forget ( ) ; }
Invokes the handler, when it receives a message.
Invokes the handler when it receives a message .
self
handler
impl FnMut() + 'static
self
handler
impl FnMut() + 'static