mirror of
https://github.com/uber/RIBs.git
synced 2026-06-16 12:54:31 +00:00
rib-coroutines
This module is responsible for defining the coroutines extensions for the rib-base module.
Installation
dependencies {
implementation 'com.uber.rib:rib-coroutines:0.13.1'
}
Usage
RibCoroutinesConfig is a global configuration object that allows for setting custom Dispatchers and Exception Handlers. This is useful for cases like Testing or when you are unable to inject Dispatchers. For configuration in app, this should be configured in the Application onCreate() before usage.
RibCoroutinesConfig.dispatchers = DefaultRibDispatchers()
RibCoroutinesConfig.exceptionHandler = CoroutineExceptionHandler { _, exception ->
Log.e(exception)
}
Lifecycle based components such as Interactors and Workers receive a dedicated coroutineScope for usage. The coroutine is cancelled when the ScopeProvider completes.
MyInteractor: Interactor {
override fun didBecomeActive(savedInstanceState: Bundle?) {
super.didBecomeActive(savedInstanceState)
coroutineScope.launch {
//Do things in this coroutine
}
}
}