Last active
April 18, 2017 14:05
-
-
Save aem/a068047f46affd02c6be74fe783b57f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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