Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  Prepare for release 0.8.0
  Revert "Prepare for release X.Y.Z"
  Prepare for release X.Y.Z
  Make fromApplication call non-blocking the UI thread (deliveryhero#94)
  • Loading branch information
msfjarvis committed Mar 15, 2024
2 parents d810bff + 794a1b7 commit 26085eb
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.startup.Initializer
import androidx.work.Configuration
import androidx.work.WorkManager
import com.deliveryhero.whetstone.Whetstone
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking

public class WhetstoneWorkerInitializer : Initializer<WorkManager> {

Expand All @@ -21,9 +23,11 @@ public class WhetstoneWorkerInitializer : Initializer<WorkManager> {


private fun Whetstone.installWorkerFactory(application: Application) {
val parentComponent = fromApplication<WorkerComponent.ParentComponent>(application)
val configuration = Configuration.Builder()
.setWorkerFactory(parentComponent.getWorkerFactory())
.build()
val configuration = runBlocking(Dispatchers.IO) {
val parentComponent = fromApplication<WorkerComponent.ParentComponent>(application)
return@runBlocking Configuration.Builder()
.setWorkerFactory(parentComponent.getWorkerFactory())
.build()
}
WorkManager.initialize(application, configuration)
}

0 comments on commit 26085eb

Please sign in to comment.