pub fn execute_promise_sync<
  D: ApplicationDispatcherExt + 'static,
  R: Serialize,
  F: FnOnce() -> Result<R> + Send + 'static,
>(
  webview_manager: &crate::WebviewManager<D>,
  task: F,
  callback: String,
  error: String,
) {
  let webview_manager_ = webview_manager.clone();
  if let Ok(dispatcher) = webview_manager.current_webview() {
    dispatcher.send_event(webview::Event::Run(Box::new(move || {
      let callback_string =
        match format_callback_result(task().map_err(|err| err.to_string()), &callback, &error) {
          Ok(js) => js,
          Err(e) => format_callback_result(
            std::result::Result::<(), String>::Err(e.to_string()),
            &callback,
            &error,
          )
          .unwrap(),
        };
      if let Ok(dispatcher) = webview_manager_.current_webview() {
        dispatcher.eval(callback_string.as_str());
      }
    })));
  }
}
/// Synchronously executes the given task
/// and evaluates its Result to the JS promise described by the `callback` and `error` function names.
Synchronously executes the given task
and evaluates its Result to the JS promise described by the `callback` and `error` function names.
Synchronously executes the given task and evaluates its Result to the JS promise described by the ` callback ` and ` error ` function names .
pub fn execute_promise_sync<
  D: ApplicationDispatcherExt + 'static,
  R: Serialize,
  F: FnOnce() -> Result<R> + Send + 'static,
>(
  webview_manager: &crate::WebviewManager<D>,
  task: F,
  callback: String,
  error: String,
) {
  let webview_manager_ = webview_manager.clone();
  if let Ok(dispatcher) = webview_manager.current_webview() {
    dispatcher.send_event(webview::Event::Run(Box::new(move || {
      let callback_string =
        match format_callback_result(task().map_err(|err| err.to_string()), &callback, &error) {
          Ok(js) => js,
          Err(e) => format_callback_result(
            std::result::Result::<(), String>::Err(e.to_string()),
            &callback,
            &error,
          )
          .unwrap(),
        };
      if let Ok(dispatcher) = webview_manager_.current_webview() {
        dispatcher.eval(callback_string.as_str());
      }
    })));
  }
}
pub fn execute_promise_sync < D : ApplicationDispatcherExt + ' static , R : Serialize , F : FnOnce ( ) -> Result < R > + Send + ' static , > ( webview_manager : & crate :: WebviewManager < D > , task : F , callback : String , error : String , ) { let webview_manager_ = webview_manager . clone ( ) ; if let Ok ( dispatcher ) = webview_manager . current_webview ( ) { dispatcher . send_event ( webview :: Event :: Run ( Box :: new ( move | | { let callback_string = match format_callback_result ( task ( ) . map_err ( | err | err . to_string ( ) ) , & callback , & error ) { Ok ( js ) => js , Err ( e ) => format_callback_result ( std :: result :: Result :: < ( ) , String > :: Err ( e . to_string ( ) ) , & callback , & error , ) . unwrap ( ) , } ; if let Ok ( dispatcher ) = webview_manager_ . current_webview ( ) { dispatcher . eval ( callback_string . as_str ( ) ) ; } } ) ) ) ; } }
Synchronously executes the given task
and evaluates its Result to the JS promise described by the `callback` and `error` function names.
Synchronously executes the given task and evaluates its Result to the JS promise described by the ` callback ` and ` error ` function names .
webview_manager
&crate::WebviewManager<D>
task
F
callback
String
error
String
webview_manager
&crate::WebviewManager<D>
task
F
callback
String
error
String