Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active July 9, 2020 15:42
Show Gist options
  • Save manuelvicnt/7e2f74f5972493701d4545cab1e683e1 to your computer and use it in GitHub Desktop.
Save manuelvicnt/7e2f74f5972493701d4545cab1e683e1 to your computer and use it in GitHub Desktop.
Adding components to the Hilt hierarchy - 1
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Singleton
class AnalyticsRepository @Inject constructor(...) { ... }
class MainActivityAnalyticsAdapter @Inject constructor(
// AnalyticsRepository is available as it's scoped to ApplicationComponent
analyticsRepository: AnalyticsRepository,
// 💥 Build time error!
// UserDataRepository is NOT available to Hilt in MainActivity as the binding
// is not available in ActivityComponent, it's in UserComponent and it's not
// propagated down the Hilt components hierarchy
userDataRepository: UserDataRepository
) { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment