jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
Other
0 stars 0 forks source link

Delay callback initialization until after the module is loaded #36

Closed jhugman closed 1 month ago

jhugman commented 1 month ago

According to The Big O of Code Reviews, this is a O(n) change.

This PR separates out the callback registration and checksum (in other backends this is called uniffiEnsureInitialized) with the module loading.

This was found in the differences between testing against hermes in a test harness and in a React Native setting.

It does this by changing the default export of the module from an object containing FfiConverters to one containing the the initialize function and the converters.

The converters import is changed to match this new export, and the index.ts template in the generate turbo-module job is also change to call the initialize functions.