Open 7flash opened 1 year ago
Solution:
> git clone git@github.com:webui-dev/deno-webui.git
import { WebUI } from "./deno-webui/mod.ts";
const myWindow = new WebUI();
myWindow .show("<html>Hello World</html>");
await WebUI.wait();
deno run --unstable --allow-all main.ts
Thank you @7flash, That's right, in the meanwhile @JOTSR is working on this to be fixed in the main repo.
Since the current doc is tracking the next comming release there are breaking changes on the exports. For production use keep using the stable latest tag on deno.land
. If you want to test the new comming features and API import directly from the main branch of the repo (pin a commit to reduce breaking changes).
The new stable version will be available soon after we voted to remove the webui.js
from the source.
The new stable version will be available soon after we voted to remove the
webui.js
from the source.
Not sure what it means, but I have a relevant question,
Is it recommended to implement backend with bind/call between frontend in terms of performance or rather perhaps better spawn my own http server in same process?
Sorry, I meant that the current repo has an unfinished implementation. You can use the latest stable version here. Or clone the current branch, and apply the patch mentioned by @JOTSR.
About the HTTP Server, usually, webui will take care of it for you. You will receive events (clicks, calls) quickly. Many people have already used webui 2.0.3 in a production environment, and it's working fine, with no performance issues.
Sorry, I meant that the current repo has an unfinished implementation. You can use the latest stable version here. Or clone the current branch, and apply the patch mentioned by @JOTSR.
About the HTTP Server, usually, webui will take care of it for you. You will receive events (clicks, calls) quickly. Many people have already used webui 2.0.3 in a production environment, and it's working fine, with no performance issues.
Another issue, I'm not sure if it's supposed to support async handlers of events, and in that case I should open another issue with more detailed description, but what happens that it works with one or two invocations, and then throws a fatal error:
malloc(): unaligned fastbin chunk detected
I don't know if it can be easily fixed to support async handlers and in meantime I will have to stick with following approach, where I have to manually register callback on frontend, then call backend function which will run callback passing result.
// frontend
window.cb = (result) => {}
window.webui.call('first_function', {});
// backend
myWindow.bind('first_function', async event => {
const result = await secondFunction();
myWindow.run(`window.cb(${result})`);
})
Do you mean this is causes issues:
webui_fn('first_function').then((response) => {
window.cb(response);
});
1) create main.ts
2) run
3) shows an error