providesCoroutineScope
Provides a singleton CoroutineScope tied to the application lifecycle.
This scope:
Lives for the entire application lifecycle
Uses SupervisorJob to prevent one failure from cancelling all operations
Uses DefaultDispatcher for CPU-bound background tasks
Should be used sparingly - prefer
viewModelScopefor most operations
When to Inject This
Application-wide data synchronization
Background monitoring that outlives ViewModels
Singleton services that need coroutine support
When NOT to Inject This
ViewModels → use
viewModelScopeComposables → use
rememberCoroutineScope()Repositories → use injected dispatchers with
withContext()
Return
A singleton CoroutineScope with SupervisorJob
Parameters
dispatcher
The DefaultDispatcher for CPU-intensive background tasks