joltup/react-native-threads

onmessage is null

mauriciopf opened this issue · 2 comments

When the event emitter is fired, doing a console log of self in the callback DeviceEventEmitter.addListener('ThreadMessage', (message) => {
seems that onmessage property is always null
{ onmessage: null, postMessage: [Function: postMessage] }

So the worker self.onmessage is never getting called

Can someone tell if this is true?

I'm having the same problem. Is there any update ?

My thread code look like that:

import { self } from 'react-native-threads'
console.log(self)
self.onmessage([...])

logs:

05-28 12:51:41.308 18302 18597 I ReactNativeJS:  { onmessage: null, postMessage: [Function: postMessage] }
05-28 12:51:41.310 18302 18597 E ReactNativeJS: TypeError: null is not a function (near '...t.self.onmessage...')

"react-native": "^0.61.5",
"react-native-threads": "0.0.19",

Ok, RTFM...

It is not

self.onmessage(callbackFn)

but

self.onmessage = callbackFn