I canβt get an event for my whole life to send correctly from iOS, native across the bridge, to respond to my own JS context. On the Objective-C side, I want to have a module for easily passing events across the bridge. I called this class EventEmitter and its definition is as follows:
// EventEmitter.h
and implementation:
// EventEmitter.m
I use sendDeviceEvent and sendAppEvent because I cannot get it to work.
On the JS side, the things that I register in order to receive these events in the global namespace of one of my modules (so that I know that subscribing to events will happen before the event occurs). I register like this:
console.log( 'ADDING EVENT LISTENERS' ); NativeAppEventEmitter.addListener( 'blah', test => console.log( 'TEST1', test ) ); DeviceEventEmitter.addListener( 'blah', test => console.log( 'TEST2', test ) );
In my log statements, I get the following:
2016-03-19 12:26:42.501 [trace][tid:com.facebook.React.JavaScript] ADDING EVENT LISTENERS 2016-03-19 12:26:43.613 [name redacted][348:38737] emitting blah with data [data redacted]
So, I can say that I send both the application event and the device event with the blah tag, and I registered to listen to the blah event with both DeviceEventEmitter and NativeAppEventEmitters, but I do not get back in the listeners.
What am I doing wrong? Thanks for reading!
source share