react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Support for initialization of external modules with bridge

Open silyevsk opened this issue 8 years ago • 6 comments

Issue Description

Sometimes there are RN modules that require initialization with parameters, such modules should be initialized via the extraModulesForBridge method from the RCTBridgeDelegate protocol. However, RNN initializes the bridge by itself and sets itself as the bridge delegate, thus modules with custom initialization can't be used with RNN. It would be great if support for external modules with custom initialization could be added to the RNN API.

silyevsk avatar Apr 11 '18 14:04 silyevsk

I believe we're already exposing getBridge method on both v1 and v2, is that not enough?

guyca avatar Apr 11 '18 14:04 guyca

The bridge is not enough - it's about dependency injection to modules. For example, there's some native class whose instance should be passed to one or several modules. In order to pass the instance, instead of letting react native initialize the modules with [[module alloc] init] (with no params), the module should be initialized in the bridge delegate's extraModulesForBridge method.

silyevsk avatar Apr 11 '18 16:04 silyevsk

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

stale[bot] avatar Jun 02 '18 03:06 stale[bot]

Looks like it wasn't implemented yet

silyevsk avatar Jun 04 '18 12:06 silyevsk

Added the option to delegate the bridgeManager in order to inject extraModules.

[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions bridgeManagerDelegate:delegate]

yogevbd avatar Jun 09 '18 09:06 yogevbd

This functionality was removed in V5. Is there a replacement ?

benpeke avatar May 16 '20 18:05 benpeke