mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 18:47:03 +05:30
feat(di): kick off Anvil infra
This commit is contained in:
parent
3c0a8dd392
commit
ce37903ea0
6 changed files with 99 additions and 0 deletions
18
di-scopes/build.gradle.kts
Normal file
18
di-scopes/build.gradle.kts
Normal 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)
|
||||
}
|
|
@ -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()
|
||||
}
|
|
@ -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()
|
|
@ -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<*>)
|
Loading…
Add table
Add a link
Reference in a new issue