Files
VRCT/src-ui/utils/logics/useStdoutToPython.js
2024-07-25 01:01:22 +09:00

17 lines
585 B
JavaScript

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