[Refactor] Logic: Move object structure creation to the parent file.

This commit is contained in:
Sakamoto Shiina
2024-08-27 11:06:10 +09:00
parent 2e77206080
commit 1042c5e2b9
3 changed files with 21 additions and 18 deletions

View File

@@ -1,11 +1,14 @@
import { store } from "@store";
export const useStdoutToPython = () => {
const asyncStdoutToPython = async (value) => {
const asyncStdoutToPython = async (path, value) => {
let send_object = { endpoint: path };
if (value) send_object.data = value;
// send to python
const backend_subprocess = store.backend_subprocess;
if (backend_subprocess) {
await backend_subprocess.write(JSON.stringify(value) + "\n").then(() => {
await backend_subprocess.write(JSON.stringify(send_object) + "\n").then(() => {
}).catch((err) => {
console.log(err);
});