fix(tauri) race condition on onTauriInit and no-server mode (#257)

This commit is contained in:
Lucas Fernandes Nogueira
2019-12-31 19:21:06 -03:00
committed by GitHub
parent e17c5f84b1
commit ddd0e2c3eb

View File

@@ -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);