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

Florian

12/07/2020, 10:03 AM
What happens if you combine 2 Flows and one of them throws an exception? Will it be caught in a
catch
operator I add on the resulting (combined) Flow?
✔️ 1
l

louiscad

12/07/2020, 11:52 AM
Yes, you can also just try it on play.kotl.in or in a dummy/playground project
Copy code
val flow1 = flow<Whatever> { null! }
val flow2 = flow<Whatever> { emit(whatever()) }
val flowToTest = combine(flow1, flow2) { a, b -> stuff(flow1, flow2) }
TODO("test catch operator")
f

Florian

12/08/2020, 9:28 AM
thank you
that play site is useful, I'll use that in the future
l

louiscad

12/08/2020, 9:28 AM
It's quite similar to a brand new project though
f

Florian

12/08/2020, 9:31 AM
well I'm using Android Studio
l

louiscad

12/08/2020, 9:31 AM
You can have IntelliJ next to it, doesn't hurt 🙂
Also, once you created the project I'm pretty sure you can open it in Android Studio if needed.
f

Florian

12/08/2020, 9:32 AM
makes sense, thank you
b

bezrukov

12/08/2020, 12:57 PM
you can just write
Copy code
fun main() {
}
in any file in Android Studio at the top (below imports, if there are any), to test anything (Run button will appear in the left side bar to
fun main
)
l

louiscad

12/08/2020, 1:05 PM
It will take longer to compile than a blank project though
b

bezrukov

12/08/2020, 1:15 PM
yes, but you will have an access to the project codebase. Plus, if a project modularized enough compile will be quite fast (faster than opening idea 🙂) in leaf module
l

louiscad

12/08/2020, 2:36 PM
Well, I have IDEA open already 😄
f

Florian

12/09/2020, 11:17 AM
@bezrukov that's very cool, thank you
4 Views