Skip to content

Commit

Permalink
Merge pull request #34 from amzn/rwo/sample
Browse files Browse the repository at this point in the history
Adopt pre-defined scopes in sample app
  • Loading branch information
vRallev authored Sep 13, 2024
2 parents 807b66d + 7e9f4e1 commit 6672dc7
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 30 deletions.
1 change: 1 addition & 0 deletions sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
kspIosSimulatorArm64 project(':compiler')

commonMainImplementation project(':runtime')
commonMainImplementation project(':runtime-optional')
commonMainImplementation libs.kotlin.inject.runtime

commonMainImplementation project(':sample:lib')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package software.amazon.lastmile.kotlin.inject.anvil.sample
import android.app.Application
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.MergeComponent
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

/**
* Concrete application component for Android using the scope [SingleInAppScope].
* Concrete application component for Android using the scope [SingleIn] [AppScope].
* [AndroidAppComponentMerged] is a generated interface. Through this merged interface
* [ApplicationIdProviderComponent], other contributed component interfaces and contributed
* bindings such as from [AndroidApplicationIdProvider] are implemented.
Expand All @@ -15,8 +17,8 @@ import software.amazon.lastmile.kotlin.inject.anvil.MergeComponent
* [Application] can be provided in the object graph.
*/
@Component
@MergeComponent
@SingleInAppScope
@MergeComponent(AppScope::class)
@SingleIn(AppScope::class)
abstract class AndroidAppComponent(
/**
* The Android application that is provided to this object graph.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package software.amazon.lastmile.kotlin.inject.anvil.sample

import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesTo

/**
* This component interface is added to the kotlin-inject component using the scope
* [SingleInAppScope] automatically.
* [AppScope] automatically.
*/
@ContributesTo
@SingleInAppScope
@ContributesTo(AppScope::class)
interface ApplicationIdProviderComponent {
/**
* Provides the [ApplicationIdProvider] from the kotlin-inject object graph.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package software.amazon.lastmile.kotlin.inject.anvil.sample
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
import platform.UIKit.UIApplication
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.MergeComponent
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

/**
* Concrete application component for iOS using the scope [SingleInAppScope].
* Concrete application component for iOS using the scope [SingleIn] [AppScope].
* [IosAppComponentMerged] is a generated interface. Through this merged interface
* [ApplicationIdProviderComponent], other contributed component interfaces and contributed
* bindings such as from [IosApplicationIdProvider] are implemented.
Expand All @@ -15,8 +17,8 @@ import software.amazon.lastmile.kotlin.inject.anvil.MergeComponent
* [UIApplication] can be provided in the object graph.
*/
@Component
@MergeComponent
@SingleInAppScope
@MergeComponent(AppScope::class)
@SingleIn(AppScope::class)
abstract class IosAppComponent(
/**
* The iOS application that is provided to this object graph.
Expand Down
1 change: 1 addition & 0 deletions sample/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ dependencies {
kspIosSimulatorArm64 project(':compiler')

commonMainImplementation project(':runtime')
commonMainImplementation project(':runtime-optional')
commonMainImplementation libs.kotlin.inject.runtime
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package software.amazon.lastmile.kotlin.inject.anvil.sample

import android.app.Application
import me.tatarka.inject.annotations.Inject
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesBinding
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

/**
* Android implementation for [ApplicationIdProvider] and provides the package name as application
Expand All @@ -12,8 +14,8 @@ import software.amazon.lastmile.kotlin.inject.anvil.ContributesBinding
* inject [ApplicationIdProvider] through the [ContributesBinding] annotation.
*/
@Inject
@SingleInAppScope
@ContributesBinding
@SingleIn(AppScope::class)
@ContributesBinding(AppScope::class)
class AndroidApplicationIdProvider(
application: Application,
) : ApplicationIdProvider {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package software.amazon.lastmile.kotlin.inject.anvil.sample

import me.tatarka.inject.annotations.Inject
import platform.UIKit.UIApplication
import software.amazon.lastmile.kotlin.inject.anvil.AppScope
import software.amazon.lastmile.kotlin.inject.anvil.ContributesBinding
import software.amazon.lastmile.kotlin.inject.anvil.SingleIn

/**
* iOS implementation for [ApplicationIdProvider] and provides a fake string as application
Expand All @@ -12,8 +14,8 @@ import software.amazon.lastmile.kotlin.inject.anvil.ContributesBinding
* inject [ApplicationIdProvider] through the [ContributesBinding] annotation.
*/
@Inject
@SingleInAppScope
@ContributesBinding
@SingleIn(AppScope::class)
@ContributesBinding(AppScope::class)
class IosApplicationIdProvider(
application: UIApplication,
) : ApplicationIdProvider {
Expand Down

0 comments on commit 6672dc7

Please sign in to comment.