Changes after review
This commit is contained in:
parent
1b054aca5b
commit
97efff8aa4
14 changed files with 130 additions and 63 deletions
|
|
@ -19,6 +19,7 @@ package io.element.android.x.architecture
|
|||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import io.element.android.x.di.DaggerComponentOwner
|
||||
|
||||
inline fun <reified T : Any> Node.bindings() = bindings(T::class.java)
|
||||
inline fun <reified T : Any> Context.bindings() = bindings(T::class.java)
|
||||
|
|
@ -27,7 +28,7 @@ fun <T : Any> Context.bindings(klass: Class<T>): T {
|
|||
// search dagger components in the context hierarchy
|
||||
return generateSequence(this) { (it as? ContextWrapper)?.baseContext }
|
||||
.plus(applicationContext)
|
||||
.filterIsInstance<io.element.android.x.di.DaggerComponentOwner>()
|
||||
.filterIsInstance<DaggerComponentOwner>()
|
||||
.map { it.daggerComponent }
|
||||
.flatMap { if (it is Collection<*>) it else listOf(it) }
|
||||
.filterIsInstance(klass)
|
||||
|
|
@ -38,7 +39,7 @@ fun <T : Any> Context.bindings(klass: Class<T>): T {
|
|||
fun <T : Any> Node.bindings(klass: Class<T>): T {
|
||||
// search dagger components in node hierarchy
|
||||
return generateSequence(this, Node::parent)
|
||||
.filterIsInstance<io.element.android.x.di.DaggerComponentOwner>()
|
||||
.filterIsInstance<DaggerComponentOwner>()
|
||||
.map { it.daggerComponent }
|
||||
.flatMap { if (it is Collection<*>) it else listOf(it) }
|
||||
.filterIsInstance(klass)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue