https://kotlinlang.org logo
#coroutines
Title
# coroutines
j

Jérôme Gully

01/18/2020, 11:32 AM
Stupid question: Using GlobalScope in the Application class of an Android app is the same than creating a specific scope in the Application class, isn't it ?
p

Paul Woitaschek

01/18/2020, 11:50 AM
Nope the globalScope is not tied to the creation off the application class
For example a contentprovider gets created before the application so using the GlobalScope there is fine but not the application scope
j

Jérôme Gully

01/18/2020, 12:23 PM
Okey thanks. But I mean, using GlobalScope in Application is okey ?
p

Paul Woitaschek

01/18/2020, 12:25 PM
Depends on you, I never use it but inject it so I can swap it out in tests
👍 1
s

streetsofboston

01/18/2020, 5:03 PM
GlobalScope has no Job and is therefore not cancellable. If that's what you want use it. Creating your own scope, even if it is a app wide singleton, it will be cancellable.
👌 2
2 Views