Skip to content

Commit

Permalink
fix webview_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Winterreisender committed Nov 3, 2024
1 parent 37a1d7c commit e04c3fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libwebview-nodejs/src/webview_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ Napi::Value _wrap_webview_dispatch(const Napi::CallbackInfo &info) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "webview_dispatch" "', argument " "2"" of type '" "void (*)(webview_t,void *)""'");
}

jsCallback = new Napi::FunctionReference(Napi::Persistent(info[1].As<Napi::Function>())); // TODO: delete jsCallback
jsCallback = new Napi::FunctionReference(Napi::Persistent(info[1].As<Napi::Function>()));
jsCallback->SuppressDestruct();

webview_dispatch(
Expand Down
9 changes: 3 additions & 6 deletions src/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ export class Webview {
* @param fn the function to be executed on the main thread.
*/
dispatch(fn) {
throw "Not Implemeted";
// let callback = Callback('void',['pointer','pointer'], (_,arg) => {
// fn(this);
// });
// libwebview.webview_dispatch(this.webview ,callback);
// process.on('exit', function() { callback; });
let callback = (w,args)=>{fn(this)};
libwebview.webview_dispatch(this.webview, callback, null);
process.on('exit', function() { callback; });
}

/** Removes a callback that was previously set by `webview_bind`.
Expand Down

0 comments on commit e04c3fe

Please sign in to comment.