Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onmessage is null #99

Open
mauriciopf opened this issue Feb 25, 2020 · 2 comments
Open

onmessage is null #99

mauriciopf opened this issue Feb 25, 2020 · 2 comments

Comments

@mauriciopf
Copy link

mauriciopf commented Feb 25, 2020

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?

@roaringUnicorn
Copy link

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",

@roaringUnicorn
Copy link

Ok, RTFM...

It is not

self.onmessage(callbackFn)

but

self.onmessage = callbackFn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants