Configuration
Gradle
The simple way to apply Tangle is to just apply the Gradle plugin.
You can also just add dependencies yourself, without applying the plugin:
- Kotlin Dependencies
- Groovy Dependencies
// 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.14.0")
anvil("com.rickbusarow.tangle:tangle-fragment-compiler:0.14.0")
// ViewModels
api("com.rickbusarow.tangle:tangle-viewmodel-api:0.14.0")
anvil("com.rickbusarow.tangle:tangle-viewmodel-compiler:0.14.0")
// optional Activity ViewModel support
implementation("com.rickbusarow.tangle:tangle-viewmodel-activity:0.14.0")
// optional Compose ViewModel support
implementation("com.rickbusarow.tangle:tangle-viewmodel-compose:0.14.0")
// optional Fragment ViewModel support
implementation("com.rickbusarow.tangle:tangle-viewmodel-fragment:0.14.0")
// WorkManager
api("com.rickbusarow.tangle:tangle-work-api:0.14.0")
anvil("com.rickbusarow.tangle:tangle-work-compiler:0.14.0")
}
// any Android module's build.gradle
plugins {
id 'android-library' // or application, etc.
kotlin("android")
id 'com.squareup.anvil'
}
dependencies {
// Fragments
api 'com.rickbusarow.tangle:tangle-fragment-api:0.14.0'
anvil 'com.rickbusarow.tangle:tangle-fragment-compiler:0.14.0'
// ViewModels
api 'com.rickbusarow.tangle:tangle-viewmodel-api:0.14.0'
anvil 'com.rickbusarow.tangle:tangle-viewmodel-compiler:0.14.0'
// optional Activity ViewModel support
implementation 'com.rickbusarow.tangle:tangle-viewmodel-activity:0.14.0'
// optional Compose ViewModel support
implementation 'com.rickbusarow.tangle:tangle-viewmodel-compose:0.14.0'
// optional Fragment ViewModel support
implementation 'com.rickbusarow.tangle:tangle-viewmodel-fragment:0.14.0'
// WorkManager
api 'com.rickbusarow.tangle:tangle-work-api:0.14.0'
anvil 'com.rickbusarow.tangle:tangle-work-compiler:0.14.0'
}
Setting up the Tangle graph
In order to connect Tangle to your application-scoped Dagger component,
call TangleGraph.add(...)
immediately after creating the component.
import android.app.Application
import tangle.inject.TangleGraph
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val myAppComponent = DaggerMyAppComponent.factory()
.create(this)
TangleGraph.add(myAppComponent)
}
}
Next steps
Tangle is now able to generate its code and hook in to Dagger.
Check out these features to start using Tangle in your project: