Hacker News new | ask | show | jobs
by laex 2890 days ago
Agreed. Creating bridging modules aren't that complicated. For anyone interested, I've linked a sample of a bridging module from my open-source project, for both IOS and Android. See [0] & [1]

The bridge creates an interface between an embedded webserver to react native.

Things to note:

1. Always dispatch bridging methods to their own threads. On IOS you can do this via. dispatch_async. On Android, you can utilise native threads or some kind of task management library. I like Bolts [2].

2. Always create bridging methods that resolve promises. This makes it easy to utilise async / await paradigm on the JS side.

[0] Android: https://github.com/hemantasapkota/react-native-web-server/tr...

[1] IOS: https://github.com/hemantasapkota/react-native-web-server/tr...

[2] Bolts: https://github.com/BoltsFramework/Bolts-Android