In this video I take you through a beginner level kotlin coroutines example. Specifically, this example is about kotlin coroutine jobs.
In the past, handling things like: Network timeouts, cancellations, multiple asychronous operations at once, were all very difficult.
- AsyncTask it was a nightmare
- Executors was an improvement but still not great
- RxJava is pretty good
- BUT coroutines are by far the BEST
Coroutines have an object called "Completable Job".
Why you should care about a completable job:
- Can be used to launch coroutines in their own independent context.
- Job that can be completed manually by you (you have more control)
- Ability to very easily cancel jobs and create new ones
- Take action when a job is cancelled
- Example: throw exception, display toast, display error dialog
Instagram:
code:
0 Comments