feat(di): kick off Anvil infra

This commit is contained in:
Harsh Shandilya 2022-11-13 13:13:03 +05:30
parent 3c0a8dd392
commit ce37903ea0
No known key found for this signature in database
6 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,18 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
kotlin("jvm")
id("dev.msfjarvis.claw.kotlin-library")
alias(libs.plugins.anvil)
}
dependencies {
implementation(libs.dagger)
implementation(libs.javax.inject)
}

View file

@ -0,0 +1,18 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.injection
object Components {
@PublishedApi @Suppress("ObjectPropertyName") internal val _components = mutableSetOf<Any>()
fun add(component: Any) {
_components.add(component)
}
inline fun <reified T> get(): T = _components.filterIsInstance<T>().single()
}

View file

@ -0,0 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.injection.scopes
abstract class AppScope private constructor()

View file

@ -0,0 +1,12 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.injection.scopes
import javax.inject.Scope
import kotlin.reflect.KClass
@Scope @Retention(AnnotationRetention.RUNTIME) annotation class SingleIn(val clazz: KClass<*>)