Answer the question
In order to leave comments, you need to log in
How to pass class method to node.js worker_teards?
Hello!
if (isMainThread) {
let modelUpDown = new Easy(
[500]
)
const worker = new Worker(__filename, {})
worker.on('message', (msg) => {
console.log(msg)
})
worker.postMessage(modelUpDown) // передаю класс воркеру
} else {
parentPort.on('message', msg => {
msg.action() //вызываю метод класса и в итоге он undefined. Как мне вызвать этот метод?
})
}
Answer the question
In order to leave comments, you need to log in
Because functions are not a serializable object
If anything, serialize this: https://nodejs.org/docs/latest-v12.x/api/v8.html#v...
You can send a message, and the stream method must call itself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question