From 52c74a1c33ce12b93ec5830f5a6348d9578c7c6e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Jun 2025 08:37:34 +0200 Subject: Simplify callback business (web version) --- web/http/worker.mjs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'web/http/worker.mjs') diff --git a/web/http/worker.mjs b/web/http/worker.mjs index d912e8b..0c1acb9 100644 --- a/web/http/worker.mjs +++ b/web/http/worker.mjs @@ -1,14 +1,16 @@ import Nissy from "./nissy_web_module.mjs" const nissy = await Nissy(); -const log = (msg) => postMessage({ command: "log", id: -1, object: msg }); -nissy.setLogger(nissy._addCallbackFunction(log)); -var solveStatus = nissy.statusRUN; // For now this is a global variable -const pollStatusCallback = nissy._addCallbackFunction(() => { -console.log("Calling pollstatus, returning " + solveStatus); -return solveStatus; +const log = (cstr) => postMessage({ + command: "log", id: -1, + object: nissy.UTF8ToString(cstr) }); +nissy.setLogger(nissy.addFunction(log, "vp")); + +var solveStatus = nissy.statusRUN; // For now this is a global variable +const pollStatus = () => solveStatus; +const pollStatusCallback = nissy.addFunction(pollStatus, "i"); const commands = [ { name: "load solver data", exec: loadSolverDataFromStorage }, -- cgit v1.3