Last active
July 9, 2020 15:42
-
-
Save manuelvicnt/7e2f74f5972493701d4545cab1e683e1 to your computer and use it in GitHub Desktop.
Adding components to the Hilt hierarchy - 1
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
/* 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