Skip to content

Instantly share code, notes, and snippets.

@aem
Last active April 18, 2017 14:05
Show Gist options
  • Save aem/a068047f46affd02c6be74fe783b57f7 to your computer and use it in GitHub Desktop.
Save aem/a068047f46affd02c6be74fe783b57f7 to your computer and use it in GitHub Desktop.
// Inside of a Dagger module
@Singleton
@Provides
fun provideReactInstanceManager(context: Context): ReactInstanceManager {
return ReactInstanceManager.builder()
.setApplication(HubspotOneApp.get(context))
.addPackage(MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(BEFORE_RESUME)
.setJSMainModuleName("index.android")
.setBundleAssetName("index.android.bundle")
.build()
}
// Then, in an Anvil view:
@Inject
lateinit var reactInstanceManager: ReactInstanceManager
/* ... */
v(ReactRootView::class.java) {
init {
Anvil.currentView<ReactRootView>().startReactApplication(reactInstanceManager, "MyComponent", null)
reactInstanceManager.onHostResume(rootActivity, rootActivity)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment