configuration
The TangleGraph
holder needs to be initialized with an application-scoped Dagger Component in
order to complete the graph.
import android.app.Application
import tangle.inject.TangleGraph
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val myAppComponent = DaggerAppComponent.factory()
.create(this)
TangleGraph.init(myAppComponent)
}
}
Gradle plugin
The simple way to apply Tangle is to just apply the gradle plugin. It will automatically add the dependencies and perform some basic validation of your module's configuration.
// settings.gradle.kts
pluginManagement {
repositories {
gradlePluginPortal()
}
}
// top-level build.gradle.kts
plugins {
id("com.rickbusarow.tangle") version "0.11.1"
}
// any Android module's build.gradle.kts
plugins {
id("android-library") // or application, etc.
kotlin("android")
id("com.squareup.anvil")
id("com.rickbusarow.tangle")
}
// optional
tangle {
composeEnabled.set(true) // default is false
fragmentsEnabled.set(true) // default is true
viewModelsEnabled.set(true) // default is true
}
Explicit dependencies
You can also just add dependencies yourself, without applying the plugin.
Note that Tangle is specifically for Android and has Android-specific dependencies, so it should only be added to Android modules.
// any Android module's build.gradle.kts
plugins {
id("android-library") // or application, etc.
kotlin("android")
id("com.squareup.anvil")
}
dependencies {
// Fragments
api("com.rickbusarow.tangle:tangle-fragment-api:0.11.1")
anvil("com.rickbusarow.tangle:tangle-fragment-compiler:0.11.1")
// ViewModels
api("com.rickbusarow.tangle:tangle-viewmodel-api:0.11.1")
anvil("com.rickbusarow.tangle:tangle-viewmodel-compiler:0.11.1")
// optional Compose support
implementation("com.rickbusarow.tangle:tangle-viewmodel-compose:0.11.1")
}