https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

Vincent Williams

07/20/2020, 11:20 PM
Hey stupid question but how do I use the new StateFlow? Im using kotlin version 1.3.72 but it doesnt seem to have StateFlow
o

octylFractal

07/20/2020, 11:25 PM
Flows/coroutines are part of the coroutines library, you need to have that
v

Vincent Williams

07/20/2020, 11:26 PM
so I thought that initially, however I dont have those libraries in my project but I still have access to most coroutines stuff (Dispatches, Channels, Flows etc)
just not StateFlow
o

octylFractal

07/20/2020, 11:26 PM
you probably have it under the
experimental
package
or something else is putting it on your classpath
v

Vincent Williams

07/20/2020, 11:27 PM
Its under the kotlinx pacakge
is that the same thing?
o

octylFractal

07/20/2020, 11:27 PM
the official package is
kotlinx.coroutines
v

Vincent Williams

07/20/2020, 11:27 PM
kotlinx.coroutines.flow for example
o

octylFractal

07/20/2020, 11:27 PM
yes, that's official
v

Vincent Williams

07/20/2020, 11:27 PM
yes I already have that then
o

octylFractal

07/20/2020, 11:27 PM
so it sounds like something else is putting it on your classpath
v

Vincent Williams

07/20/2020, 11:27 PM
🤔 any idea what would be doing that?
o

octylFractal

07/20/2020, 11:28 PM
check with your build tool
v

Vincent Williams

07/20/2020, 11:28 PM
do any of the jetpack libraries do that for some reason?
o

octylFractal

07/20/2020, 11:28 PM
oh, android? something probably does
check
gradle dependencies
v

Vincent Williams

07/20/2020, 11:28 PM
ya sorry this is in Android. In my dependencies, I dont have the coroutines library specifically
but I have a lot of google libraries
maybe its a transitive dependency?
anyway, which of the listed dependencies do I actually need for stateflow?
just the core package?
o

octylFractal

07/20/2020, 11:32 PM
just the core one
and when I said,
gradle dependencies
, I meant to run that command
it will print out transitive dependencies too
v

Vincent Williams

07/20/2020, 11:34 PM
ok ill run it and see. Thanks for the help, I thought coroutines came standard with kotlin for some reason
o

octylFractal

07/20/2020, 11:34 PM
nope, just the
suspend
modifier
v

Vincent Williams

07/20/2020, 11:38 PM
ya turns out it was google libraries that use it
a

andylamax

07/20/2020, 11:51 PM
StateFlow is in version 1.3.6/7 and above I believe
5 Views