[Refactor] Separate Logics directory.
This commit is contained in:
17
src-ui/logics/useStdoutToPython.js
Normal file
17
src-ui/logics/useStdoutToPython.js
Normal file
@@ -0,0 +1,17 @@
|
||||
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user