pub fn start(&mut self) {
        // Clone and bind internal states
        let state_here = self.state.clone();
        let state_moved = self.state.clone();
        // Create closure for startup process
        let closure = Closure::new(move |e: MessageEvent| {
            // Bind state to local variable
            let state = state_moved.clone();
            // Parse UI request
            let check: String = e.data().as_string().unwrap();
            // Check if UI is ready for further action
            if check == "initAck" {
                // If so, remove closure for startup process as listener
                remove_message_listener(&"message", &state.init_closure().as_ref().unwrap());
                state.set_init_closure(None);
                // Create new closure for main process
                let closure
                    = Backend::build_main_closure(state_moved.clone());
                // Bind closure for main process to message listener
                add_message_listener(&"message", &closure);
                // Save closure in state
                state.set_main_closure(Some(closure));
            }
        });
        // Bind closure for startup process to message listener
        add_message_listener(&"message", &closure);
        // Save closure in state
        state_here.set_init_closure(Some(closure));
        // Finish initialization with worker setup
        let _ = future_to_promise(async move {
            // Bind state to local variable
            let state = state_here;
            // TODO is this future needed? Init is done in login now
            // Initialize worker
            // let _ = state.worker().init().await;
            // Tell UI initialization is done
            post_message(&JsValue::from("initDone"));
            Ok(JsValue::from(true))
        });
    }
/// Starts the whole Backend.
/// Creates message listeners for UI requests.
/// Also database are initialized and managed.
Starts the whole Backend.
Creates message listeners for UI requests.
Also database are initialized and managed.
Starts the whole Backend . Creates message listeners for UI requests . Also database are initialized and managed .
pub fn start(&mut self) {
        // Clone and bind internal states
        let state_here = self.state.clone();
        let state_moved = self.state.clone();
        // Create closure for startup process
        let closure = Closure::new(move |e: MessageEvent| {
            // Bind state to local variable
            let state = state_moved.clone();
            // Parse UI request
            let check: String = e.data().as_string().unwrap();
            // Check if UI is ready for further action
            if check == "initAck" {
                // If so, remove closure for startup process as listener
                remove_message_listener(&"message", &state.init_closure().as_ref().unwrap());
                state.set_init_closure(None);
                // Create new closure for main process
                let closure
                    = Backend::build_main_closure(state_moved.clone());
                // Bind closure for main process to message listener
                add_message_listener(&"message", &closure);
                // Save closure in state
                state.set_main_closure(Some(closure));
            }
        });
        // Bind closure for startup process to message listener
        add_message_listener(&"message", &closure);
        // Save closure in state
        state_here.set_init_closure(Some(closure));
        // Finish initialization with worker setup
        let _ = future_to_promise(async move {
            // Bind state to local variable
            let state = state_here;
            // TODO is this future needed? Init is done in login now
            // Initialize worker
            // let _ = state.worker().init().await;
            // Tell UI initialization is done
            post_message(&JsValue::from("initDone"));
            Ok(JsValue::from(true))
        });
    }
pub fn start ( & mut self ) { // Clone and bind internal states let state_here = self . state . clone ( ) ; let state_moved = self . state . clone ( ) ; // Create closure for startup process let closure = Closure :: new ( move | e : MessageEvent | { // Bind state to local variable let state = state_moved . clone ( ) ; // Parse UI request let check : String = e . data ( ) . as_string ( ) . unwrap ( ) ; // Check if UI is ready for further action if check == " " { // If so, remove closure for startup process as listener remove_message_listener ( & " " , & state . init_closure ( ) . as_ref ( ) . unwrap ( ) ) ; state . set_init_closure ( None ) ; // Create new closure for main process let closure = Backend :: build_main_closure ( state_moved . clone ( ) ) ; // Bind closure for main process to message listener add_message_listener ( & " " , & closure ) ; // Save closure in state state . set_main_closure ( Some ( closure ) ) ; } } ) ; // Bind closure for startup process to message listener add_message_listener ( & " " , & closure ) ; // Save closure in state state_here . set_init_closure ( Some ( closure ) ) ; // Finish initialization with worker setup let _ = future_to_promise ( async move { // Bind state to local variable let state = state_here ; // TODO is this future needed? Init is done in login now // Initialize worker // let _ = state.worker().init().await; // Tell UI initialization is done post_message ( & JsValue :: from ( " " ) ) ; Ok ( JsValue :: from ( true ) ) } ) ; }
Starts the whole Backend.
Starts the whole Backend .
&mut self
&mut self