Replies: 4 comments
-
This sounds interesting - btw, have you looked into the TurboModules #40? |
Beta Was this translation helpful? Give feedback.
-
Not yet. Edit: |
Beta Was this translation helpful? Give feedback.
-
@a1lu TurboModules won't block the js thread, because there is "no bridge" (it is but in some different way). Also, I didn't get why did you use It would better to try to use some more native approach for both android and ios - some kind of event emitter. I'm not an expert, but I'm pretty sure it exists for both platforms. |
Beta Was this translation helpful? Give feedback.
-
I'm using a 3rd party lib that uses |
Beta Was this translation helpful? Give feedback.
-
Feature Request
Why it is needed
Modules that send a lot of events (in my case bluetooth notifications) put a lot load on the js bridge. If you don't need this data in javascript code but only in another native module this load is unnecessary.
If you want to use the existing modules environment and don't want to reinvent the wheel there is AFAIK no way to avoid this.
A better way would be to subscribe the events from the native module and keep the data in native land.
Possible implementation
The subscriber could subscribe the event in the react context object. If another modules sends a event, this event could be queued in a blocking queue for each subscriber. The subscriber can than fetch the event in a thread or poll this queue.
E.g.
I am not an android or iOS expert, so maybe there is a better solution to send events in native.
In my project I patched a 3rd party bluetooth library I am using to put the event parameters into a global queue (android only) and my modules fetches the data in a thread like shown above. This reduced the cpu load by 5 to 10% on a Moto G5.
Best regards
Beta Was this translation helpful? Give feedback.
All reactions