Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active July 9, 2020 15:40
Show Gist options
  • Save manuelvicnt/95d936f5ef221199d298276312a1d114 to your computer and use it in GitHub Desktop.
Save manuelvicnt/95d936f5ef221199d298276312a1d114 to your computer and use it in GitHub Desktop.
Adding components to the Hilt hierarchy - 2
/* 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