Skip to content

Commit

Permalink
Merge pull request #31 from amzn/rwo/app-scope
Browse files Browse the repository at this point in the history
Add `AppScope` marker class
  • Loading branch information
vRallev authored Sep 12, 2024
2 parents 87eb092 + bf55024 commit db9ae48
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runtime-optional/api/android/runtime-optional.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
public abstract class software/amazon/lastmile/kotlin/inject/anvil/AppScope {
}

public abstract interface annotation class software/amazon/lastmile/kotlin/inject/anvil/ForScope : java/lang/annotation/Annotation {
public abstract fun scope ()Ljava/lang/Class;
}
Expand Down
3 changes: 3 additions & 0 deletions runtime-optional/api/jvm/runtime-optional.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
public abstract class software/amazon/lastmile/kotlin/inject/anvil/AppScope {
}

public abstract interface annotation class software/amazon/lastmile/kotlin/inject/anvil/ForScope : java/lang/annotation/Annotation {
public abstract fun scope ()Ljava/lang/Class;
}
Expand Down
2 changes: 2 additions & 0 deletions runtime-optional/api/runtime-optional.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ open annotation class software.amazon.lastmile.kotlin.inject.anvil/SingleIn : ko
final val scope // software.amazon.lastmile.kotlin.inject.anvil/SingleIn.scope|{}scope[0]
final fun <get-scope>(): kotlin.reflect/KClass<*> // software.amazon.lastmile.kotlin.inject.anvil/SingleIn.scope.<get-scope>|<get-scope>(){}[0]
}

abstract class software.amazon.lastmile.kotlin.inject.anvil/AppScope // software.amazon.lastmile.kotlin.inject.anvil/AppScope|null[0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package software.amazon.lastmile.kotlin.inject.anvil

/**
* Scope marker for the application scope, which gets created when the app launches. The
* application scope stays alive as long as the app itself.
*
* To make an object a singleton within the application scope, use this marker class in conjunction
* with [SingleIn], e.g.
* ```
* @Inject
* @SingleIn(AppScope::class)
* class MyClass : SuperType {
* ...
* }
* ```
*
* To contribute a component interface to the application scope, use the `ContributesTo`
* annotation:
* ```
* @ContributesTo(AppScope::class)
* interface AbcComponent {
* @Provides fun provideAbc(): Abc = ...
*
* val abc: Abc
* }
* ```
*
* To contribute a binding to the application scope, use the `ContributesBinding` annotation:
* ```
* // Allows you to inject `Service` without adding any Dagger module.
* @Inject
* @ContributesBinding(AppScope::class)
* @SingleIn(AppScope::class)
* class ServiceImpl : Service {
* ...
* }
* ```
*/
public abstract class AppScope private constructor()

0 comments on commit db9ae48

Please sign in to comment.