CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 10
Node.js setInterval #7
-
I noticed that |
Beta Was this translation helpful? Give feedback.
All reactions
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.
All reactions
-
Tried calling |
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
All reactions
-
π 1
-
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.
All reactions
-
π 1
-
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.
All reactions
-
As far as I remember, it worked if I called webview in a child thread and not in the main thread |
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
All reactions
-
Yeah, that might be the right approach indeed. Don't know if it's enough for server-heavy usecases though |
Beta Was this translation helpful? Give feedback.
All reactions
-
Well, though I'm maintaining a 'webview' project, I can recommend two similar projects for that case:
And, if your backend is heavy, you could consider writing a HTTP server and use the B/S structure in webview. |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Sorry for that because I'm not a native English speaker. I mean you can write a server seperately and let webview communicate with your server via HTTP. It's just a suggestion, I'm not an expert in writing large-scale softwares. I click the |
Beta Was this translation helpful? Give feedback.
All reactions
-
Or maybe another node process. Thanks |
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