From ddd0e2c3ebb27f240880826838da6896219cd3d7 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 31 Dec 2019 19:21:06 -0300 Subject: [PATCH] fix(tauri) race condition on onTauriInit and no-server mode (#257) --- tauri/src/app/runner.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tauri/src/app/runner.rs b/tauri/src/app/runner.rs index 175b8e235..6a3db9bfb 100644 --- a/tauri/src/app/runner.rs +++ b/tauri/src/app/runner.rs @@ -85,7 +85,15 @@ pub(crate) fn run(application: &mut crate::App) { webview.eval(" if (window.onTauriInit !== void 0) { window.onTauriInit() + window.onTauriInit = void 0 } + Object.defineProperty(window, 'onTauriInit', { + set: function(val) { + if (typeof(val) === 'function') { + val() + } + } + }) ").expect("failed to evaluate window.onTauriInit"); } else if !crate::endpoints::handle(webview, arg) { application.run_invoke_handler(webview, arg);