Last active
July 9, 2020 15:40
-
-
Save manuelvicnt/95d936f5ef221199d298276312a1d114 to your computer and use it in GitHub Desktop.
Adding components to the Hilt hierarchy - 2
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 */ | |
// Annotation for scoping to UserComponent | |
@Scope | |
@MustBeDocumented | |
@Retention(value = AnnotationRetention.RUNTIME) | |
annotation class LoggedUserScope | |
// Types scoped to this component must be annotated with @LoggedUserScope | |
@LoggedUserScope | |
// Make UserComponent subcomponent of ApplicationComponent | |
@DefineComponent(parent = ApplicationComponent::class) | |
interface UserComponent { | |
// Builder to create instances of UserComponent | |
@DefineComponent.Builder | |
interface Builder { | |
fun setUser(@BindsInstance user: User): UserComponent.Builder | |
fun build(): UserComponent | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment