Files
VRCT/src-ui/logics/useStdoutToPython.js
Sakamoto Shiina ef5eb2fb40 [Update/Perf] Config Page: Device Tab. Add threshold_component(dev).
Improve re-render, unnecessary, problem.
2024-09-07 21:32:44 +09:00

21 lines
753 B
JavaScript

import { store } from "@store";
import { encode } from "js-base64";
export const useStdoutToPython = () => {
const asyncStdoutToPython = async (path, value) => {
let send_object = { endpoint: path };
if (value) send_object.data = encode(JSON.stringify(value));
// send to python
const backend_subprocess = store.backend_subprocess;
if (backend_subprocess) {
await backend_subprocess.write(JSON.stringify(send_object) + "\n").then(() => {
}).catch((err) => {
console.log(err);
});
} else {
console.error("Backend subprocess is not found.", backend_subprocess);
}
};
return { asyncStdoutToPython };
};