With Kotlin 1.3 one can launch job using GlobalScope.launch
but one thing that I can't seem to figure out is how to keep track of Job
returned by ``GlobalScope.launch` and cancel all pending jobs if they are active.
In older version of launch
one could specify parent = parentJob
and one could simply cancel parentJob. But when using GlobalScope.launch
how does one cancel all pending jobs (easily) so from say ViewModel's onCleared one can cancel all pending stuff.
So basically it turns out you can either have your ViewModel/AppComptActivity etc. inherit from CoroutineScope. Or you can use composition like this:
```
```
Then in appropriate destroy method call
pendingJobs.cancel()
to terminate pending jobs.