https://kotlinlang.org logo
#dagger
Title
e

enighma

09/27/2021, 11:04 PM
Update 2:
Copy code
@JvmSuppressWildcards
Adding that to the constructor injection site did the trick. @ephemient thank you! 🙂 Update 1: In my use-case below
MyType
was a sealed class, which is what caused the issue. Original message: I think this question applies here even though I'm using hilt: I have a provider function that provides a kotlinflow like so:
fun provideX(): Flow<MyType>
However, when I try to compile I get "cannot be provided without an @Provides-annotated method". I'm guessing it wants a provider for MyType? I'm not sure, because it seems to work if it's:
fun provideX(): Flow<Long>
I guess in general, are there any recommendation around flows/async together with dagger/hilt?
e

ephemient

09/27/2021, 11:20 PM
@JvmSuppressWildcards
e

enighma

09/27/2021, 11:32 PM
Thanks, but that didn't work. This is what I have with your suggestion
Copy code
@JvmSuppressWildcards
@Provides
fun providesTokenImpl(tokenManager: TokenManager): StateFlow<Token> {
and Token is a sealed class:
Copy code
sealed class Token
object NoToken : Token()
data class RealToken(
If I change the provides to
StateFlow<RealToken>
it works 😕
Got it working by adding that to the injection site. Thanks you!
2 Views