Skip to content

Commit 8d533e8

Browse files
committed
Other cleanup
1 parent ad8ad3d commit 8d533e8

File tree

11 files changed

+14
-20
lines changed

11 files changed

+14
-20
lines changed

appnav/src/main/kotlin/io/element/android/appnav/LoggedInAppScopeFlowNode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import io.element.android.libraries.matrix.ui.media.ImageLoaderHolder
3636
import kotlinx.parcelize.Parcelize
3737

3838
/**
39-
* `LoggedInAppScopeFlowNode` is a Node responsible to set up the Dagger
39+
* `LoggedInAppScopeFlowNode` is a Node responsible to set up the Session graph.
4040
* [io.element.android.libraries.di.SessionScope]. It has only one child: [LoggedInFlowNode].
4141
* This allow to inject objects with SessionScope in the constructor of [LoggedInFlowNode].
4242
*/

docs/_developer_onboarding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Here are the main points:
260260
2. Views are compose first
261261
3. Presenters are also compose first, and have a single `present(): State` method. It's using the power of compose-runtime/compiler.
262262
4. The point of connection between a `View` and a `Presenter` is a `Node`.
263-
5. A `Node` is also responsible for managing Dagger components if any.
263+
5. A `Node` is also responsible for managing DI graph if any, see for instance `LoggedInAppScopeFlowNode`.
264264
6. A `ParentNode` has some children `Node` and only know about them.
265265
7. This is a single activity full compose application. The `MainActivity` is responsible for holding and configuring the `RootNode`.
266266
8. There is no more needs for Android Architecture Component ViewModel as configuration change should be handled by Composable if needed.
@@ -422,7 +422,7 @@ Rageshake can be very useful to get logs from a release version of the applicati
422422
- When this is possible, prefer using `sealed interface` instead of `sealed class`;
423423
- When writing temporary code, using the string "DO NOT COMMIT" in a comment can help to avoid committing things by mistake. If committed and pushed, the CI
424424
will detect this String and will warn the user about it. (TODO Not supported yet!)
425-
- Very occasionally the gradle cache misbehaves and causes problems with Dagger. Try building with `--no-build-cache` if Dagger isn't behaving how you expect.
425+
- Very occasionally the gradle cache misbehaves and causes problems with code generation. Adding `--no-build-cache` to the `gradlew` command line can help to fix compilation issue.
426426

427427
## Happy coding!
428428

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemEventContentKey.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlin.reflect.KClass
1313

1414
/**
1515
* Annotation to add a factory of type [TimelineItemPresenterFactory] to a
16-
* Dagger map multi binding keyed with a subclass of [TimelineItemEventContent].
16+
* dependency injection map multi binding keyed with a subclass of [TimelineItemEventContent].
1717
*/
1818
@Retention(AnnotationRetention.RUNTIME)
1919
@MapKey

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactories.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.element.android.libraries.di.RoomScope
2020
import kotlin.reflect.KClass
2121

2222
/**
23-
* Dagger module that declares the [TimelineItemPresenterFactory] map multi binding.
23+
* Container that declares the [TimelineItemPresenterFactory] map multi binding.
2424
*
2525
* Its sole purpose is to support the case of an empty map multibinding.
2626
*/

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/di/TimelineItemPresenterFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import io.element.android.libraries.architecture.Presenter
1313
/**
1414
* A factory for a [Presenter] associated with a timeline item.
1515
*
16-
* Implementations should be annotated with [AssistedFactory] to be created by Dagger.
16+
* Implementations should be annotated with [dev.zacsweers.metro.AssistedFactory] to be created by the dependency injection library.
1717
*
1818
* @param C The timeline item's [TimelineItemEventContent] subtype.
1919
* @param S The [Presenter]'s state class.

libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/Bindings.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import android.content.ContextWrapper
1212
import com.bumble.appyx.core.node.Node
1313
import io.element.android.libraries.di.DependencyInjectionGraphOwner
1414

15-
inline fun <reified T : Any> Node.optionalBindings() = optionalBindings(T::class.java)
1615
inline fun <reified T : Any> Node.bindings() = bindings(T::class.java)
1716
inline fun <reified T : Any> Context.bindings() = bindings(T::class.java)
1817

1918
fun <T : Any> Context.bindings(klass: Class<T>): T {
20-
// search dagger components in the context hierarchy
19+
// search the components in the dependency injection graph
2120
return generateSequence(this) { (it as? ContextWrapper)?.baseContext }
2221
.plus(applicationContext)
2322
.filterIsInstance<DependencyInjectionGraphOwner>()
@@ -28,16 +27,13 @@ fun <T : Any> Context.bindings(klass: Class<T>): T {
2827
?: error("Unable to find bindings for ${klass.name}")
2928
}
3029

31-
fun <T : Any> Node.optionalBindings(klass: Class<T>): T? {
32-
// search dagger components in node hierarchy
30+
fun <T : Any> Node.bindings(klass: Class<T>): T {
31+
// search the components in the node hierarchy
3332
return generateSequence(this, Node::parent)
3433
.filterIsInstance<DependencyInjectionGraphOwner>()
3534
.map { it.graph }
3635
.flatMap { it as? Collection<*> ?: listOf(it) }
3736
.filterIsInstance(klass)
3837
.firstOrNull()
39-
}
40-
41-
fun <T : Any> Node.bindings(klass: Class<T>): T {
42-
return optionalBindings(klass) ?: error("Unable to find bindings for ${klass.name}")
38+
?: error("Unable to find bindings for ${klass.name}")
4339
}

libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/NodeFactories.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ inline fun <reified N : Node> NodeFactoriesBindings.createNode(
3737
val nodeClass = N::class
3838
val nodeFactoryMap = nodeFactories()
3939
// Note to developers: If you got the error below, make sure to build again after
40-
// clearing the cache (sometimes several times) to let Dagger generate the NodeFactory.
40+
// clearing the cache (sometimes several times) to let codegen generate the NodeFactory.
4141
val nodeFactory = nodeFactoryMap[nodeClass] ?: error("Cannot find NodeFactory for ${nodeClass.java.name}.")
4242

4343
@Suppress("UNCHECKED_CAST")

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemEventContentKey.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlin.reflect.KClass
1313

1414
/**
1515
* Annotation to add a factory of type [MediaItemPresenterFactory] to a
16-
* Dagger map multi binding keyed with a subclass of [MediaItem.Event].
16+
* DI map multi binding keyed with a subclass of [MediaItem.Event].
1717
*/
1818
@Retention(AnnotationRetention.RUNTIME)
1919
@MapKey

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactories.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.element.android.libraries.mediaviewer.impl.model.MediaItem
2020
import kotlin.reflect.KClass
2121

2222
/**
23-
* Dagger module that declares the [MediaItemPresenterFactory] map multi binding.
23+
* Container that declares the [MediaItemPresenterFactory] map multi binding.
2424
*
2525
* Its sole purpose is to support the case of an empty map multibinding.
2626
*/

libraries/mediaviewer/impl/src/main/kotlin/io/element/android/libraries/mediaviewer/impl/gallery/di/MediaItemPresenterFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import io.element.android.libraries.mediaviewer.impl.model.MediaItem
1313
/**
1414
* A factory for a [Presenter] associated with a timeline item.
1515
*
16-
* Implementations should be annotated with [AssistedFactory] to be created by Dagger.
16+
* Implementations should be annotated with [dev.zacsweers.metro.AssistedFactory] to be created.
1717
*
1818
* @param C The timeline item's [MediaItem.Event] subtype.
1919
* @param S The [Presenter]'s state class.

0 commit comments

Comments
 (0)