Software engineer @
Developer of
and
@florianrival
4ian
✅ node-gyp
✅ Embind/WebIDL
✅ JNI
✅ C# bindings generators
✅ The bridge
✅ Bindings with SpiderMonkey
$ ls
android
ios
package.json
index.android.js
index.ios.js
Native app
JS engine
thread
Bridge
Asynchronous messages or events (sent on a queue)
Main thread
Native module thread
Arguments sent internally as JSON
Module id, method id and arguments queued
Number, String, Function, Array, Object, even Promises
Go read facebook.github.io/react-native/docs/native-modules-ios.html
Open XCode
Add an Objective-C file
Write your methods
Expose them with RCT_EXPORT_METHOD and RCT_EXPORT_MODULE
import { NativeModules } from 'react-native';
var MyModule = NativeModules.CalendarManager;
CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey');
Relaunch to recompile your app 🚀
iOS
Expose methods with @ReactMethod
Go read https://facebook.github.io/react-native/docs/native-modules-android.html
Open Android Sutdio
Add a ReactPackage
Add a ReactContextBaseJavaModule
import { NativeModules } from 'react-native';
var MyModule = NativeModules.CalendarManager;
CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey');
Relaunch to recompile your app 🚀
Android
Bootstrap an empty native module
Set up a blank React Native app
Use `file:../` in your example app to have your test bed app use the module that is in the parent directory.
npm publish
PROTIP
https://github.com/bamlab/generator-module-react-native
https://github.com/frostney/react-native-create-library
https://github.com/peggyrayzis/react-native-create-bridge
Kotlin & Swift support!
NSLog(@"Yup, I'm working");
System.out.printLn("Howdy");
https://github.com/jondot/rn-snoopy
MessageQueue.spy
💔
😅
rn-snoopy is a good way to check if that's the case or why
"congestion" on the bridge
Don't send files over the bridge 😜
Keep working with filepaths
Write large chunks of data (processed images, large computation results...) in cache if needed
Changes in the native code of React Native (headers, interfaces...) may force you to only support latest versions
Upgrade the major version when a breaking change in the interface is done
Tools like commitizen can help
@florianrival
4ian
.tech
_lab
@