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

Brendan Weinstein

04/21/2020, 1:03 AM
TIL that my coworkers are just annoyed as I am that the first auto-suggestion that comes for
flow.colle
is not the extension function that takes a lambda but the collect that takes a flowCollector. Not sure if there is something the library could do to improve that, or if it's more something for intellij (if I'm always selecting the 2nd suggestion, make it the first suggestion from there on?).
z

zak.taccardi

04/21/2020, 1:04 AM
use:
Copy code
yourFlow
  .onEach { itemInFlow ->  }
  .launchIn(scope)
👍 2
😬 3
but yeah, the internal
.collect(..)
API that appears in autocomplete is frustrating
o

octylFractal

04/21/2020, 1:08 AM
intellij can do the latter for Java at the moment, but with a disclaimer: "Completion for chained expressions is only available for Java and requires the project to be built with the IntelliJ IDEA compiler (not the Gradle compiler)." it might be a good idea to make this an formal request for adding this to Kotlin
s

streetsofboston

04/21/2020, 2:34 AM
I can't find the slack thread, but I remember Roman saying that Kotlin code should use star/wildcard imports, which would then make intellisense favor the extension function
collect
. ...
b

Brendan Weinstein

04/21/2020, 3:11 AM
Our team uses detekt with a rule against wildcard imports so that's a no go. I remember it was cumbersome to update intellij settings to prevent wildcards (there is no
never use wildcard imports
setting); I am curious if there is some divide between language designers and the community. I think the reasoning against wildcard imports is that they clutter the namespace. Maybe the counterargument is your file has too much scope if that's a problem.
👍 1
s

streetsofboston

04/21/2020, 4:18 AM
I think that Kotlin (at least some of its designers) see Kotlin using scoping through packages (and modules). Let me see if I can find Roman's post/answer about this exact same issue (and that also kicked off a star-import 'yes' or 'no' discussion).
e

elizarov

04/21/2020, 10:37 AM
The "collect" wrong-suggestion problem is going to be fixed soon. It already works much better in master branch.
🙌 5
e

Erik

04/21/2020, 10:40 AM
How did it change on master?
e

elizarov

04/21/2020, 10:42 AM
The first auto-suggestion is now an extension function.
e

Erik

04/21/2020, 10:42 AM
shipit
e

elizarov

04/21/2020, 10:43 AM
Will be in Kotlin 1.4.
e

Erik

04/21/2020, 10:44 AM
Great to hear you're working on good user APIs so much. It's what many love about Kotlin, which is why it's extra annoying when one little thing is not so smooth 👍
3 Views