![]() ![]() It also makes it harder to read for people used to coroutines because it looks like multiple values are coming, and potentially collect being infinite, but it's not the case.Įach time you write flow instead. In the provided examples you're not subscribing for updates anywhere, all flows actually just give a single element and complete, so there is no real reason to use flows and it complicates the code. You can of course also make them return Result-like classes to encapsulate errors instead of actually using exceptions, but the important part is that with suspend functions you are exposing a seemingly synchronous (thus convenient) API while still benefitting from asynchronous runtime. The Greek term Apeiron, meaning originally 'boundless' rather than 'infinite,' was used by Anaximander for the ultimate source of his universe. The most obvious problem I see here is that you're using Flow for single values instead of suspend functions.Ĭoroutines makes the single-value use case much simpler by using suspend functions that return plain values or throw exceptions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |