Node.js setInterval #7
-
I noticed that |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Thanks for your feedback! I'll try to figure out the reason later(Possibly next day). Maybe these issues in webview are related: |
Beta Was this translation helpful? Give feedback.
-
This issue is reproducible, wherever the let w = new Webview(true);
w.title("Hello World");
w.size(800,600);
w.navigate("about:blank");
w.dispatch((w)=>{
setInterval(() => {
console.log(1);
w.title("1");
},1000);
});
w.show(); |
Beta Was this translation helpful? Give feedback.
-
webview_deno has the same issue: // deno run -Ar --unstable test.js
import { Webview } from "https://deno.land/x/webview/mod.ts";
const w = new Webview();
w.navigate(`about:blank`);
setInterval(()=>{
console.log("test log");
},100);
w.run(); |
Beta Was this translation helpful? Give feedback.
-
even the nodejs worker won't work const { Webview } = require('webview-nodejs');
const { isMainThread, workerData, Worker } = require('worker_threads');
function workerThread() {
console.log(workerData);
setInterval(()=>{
console.log("Hello");
},100);
}
function mainThread() {
let w = new Webview(true);
new Worker(__filename, { workerData: w });
w.title("Hello World");
w.size(800,600);
w.navigate("about:blank");
w.show();
}
if (isMainThread) {
mainThread();
} else {
workerThread();
} |
Beta Was this translation helpful? Give feedback.
-
This could be a workaround: let w = new Webview(true);
w.navigate("about:blank");
w.bind("foo", (w) => {
// write you setInterval code here
console.log("Hello");
});
w.init("setInterval(foo,1000)");
w.show(); it uses the It may be a design of webview that, once you started the webview, you should consider the webview as the main place to write code, node.js and other backend should only deal with code that could not be done in webview |
Beta Was this translation helpful? Give feedback.
This could be a workaround:
it uses the
setInterval
in browser and call the function which is bound to the Node.js. I tested on my machine and it works.It may be a design of webview that, once you started the webview, you should consider the webview as the main place to write code, node.js and other backend should only deal with code that could not be done in webview