That's a bit outdated but most of the patterns the...
# arrow
j
That's a bit outdated but most of the patterns there still apply. I'd ignore Try, since it's recommended to use Either.catch or IO instead. Read this post for more details on that https://jorgecastillo.dev/please-try-to-use-io
👍 1
❤️ 1
m
BIO<E, A>
looks promising 😄 hopefully it’s release soon
do you have a source code for the above post? cc @Jorge Castillo -----
Copy code
service.loadAllSpeakers()
i wanna ask about the above method, by reading your post, I assume that return plain
List<Speaker>
cmiiw? also, do you have any recommendation to combine it with coroutine? or by using
IO
I don’t have to make my code like this, except using (cancelation) or, arrow already provide that as well?
Copy code
interface SpeakerService {
 fun loadAllSpeakers(): Flow<List<Speaker>>
 // or suspend function
 suspend fun loadAllSpeakers(): List<Speaker>
}
j
Hi! Sorry but I don't have the codebase for this. But yep,
loadAllSpeakers()
just retunrs the plain list of speakers.
I'd not recommend mixing kotlinx coroutines if you already got IO in place. You can use IO.fx {} which allows cancellation in a more FP way.
I recommend reading ArrowFx docs https://arrow-kt.io/docs/fx/
👍 1
Do we have docs regarding fx cancellation @simon.vergauwen?
m
ok will learn more about arrow-fx, thanks @Jorge Castillo. yes the docs would be great, looking forward soon
I see, I thought it would be great to combined it like
Room
using
Flow
(for local data source),
Retrofit
service that return an
IO
but also mapping to be inserted/updated to SQLite.
j
We don't have support for streams yet, that's something in the roadmap but might take some time
m
I see, so the
IO
better for one-shot operation?
s
@Jorge Castillo There is documentation on how to use and work with cancelation but not how it works internally
j
Yep I meant fx cancellation usage