AndroidCoroutinesHelper
AndroidCoroutinesHelper copied to clipboard
Top-level functions launch() & async() are deprecated
Not sure how you would fix this. Doesn't seem like a good idea to just shove GlobalScope. in front of those calls.
Yeah, I haven't had time to look at this properly. It should be possible, but I need to find some time to update this (and the blog post).
If you try to pass in a scope to the then() function, then that won't compile because infix functions only take a single argument.
The trick would be to put the scope on the lifecycle-listener and let that one own the coroutines.
While this approach looks nice I have some concerns about initiating coroutines from an activity or fragment. While it works, it is usually less optimal as we have the LiveData classes today. If we move the coroutines to a ViewModel, the need to pass the data back to the main thread disappears as we can do postValue() on a LiveData from a background thread.
Basically, I think my approach as it is right now is unnecessary. :)