Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package com.uber.rib.workers.root.main.ribworkerselection
enum class RibWorkerBindTypeClickType {
SINGLE_WORKER_BIND_CALLER_THREAD,
SINGLE_WORKER_BIND_BACKGROUND_THREAD,
BIND_MULTIPLE_WORKERS,
BIND_MULTIPLE_DEPRECATED_WORKERS,
BIND_MULTIPLE_RIB_COROUTINE_WORKERS,
BIND_RIB_COROUTINE_WORKER,
WORKER_TO_RIB_COROUTINE_WORKER,
RIB_COROUTINE_WORKER_TO_WORKER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ class RibWorkerSelectionInteractor(
updateViewModel(ioWorker::class.simpleName)
WorkerBinder.bind(this, ioWorker)
}
RibWorkerBindTypeClickType.BIND_MULTIPLE_WORKERS -> {
RibWorkerBindTypeClickType.BIND_MULTIPLE_DEPRECATED_WORKERS -> {
val workers = listOf(backgroundWorker, defaultWorker, ioWorker, uiWorker)
updateViewModel("Multiple workers ")
updateViewModel("Multiple deprecated workers ")
WorkerBinder.bind(this, workers)
}
RibWorkerBindTypeClickType.BIND_MULTIPLE_RIB_COROUTINE_WORKERS -> {
val workers = listOf(defaultRibCoroutineWorker, defaultRibCoroutineWorker)
updateViewModel("Multiple RibCoroutineWorkers ")
coroutineScope.bind(workers)
}
RibWorkerBindTypeClickType.BIND_RIB_COROUTINE_WORKER -> {
updateViewModel(defaultRibCoroutineWorker::class.simpleName)
coroutineScope.bind(defaultRibCoroutineWorker)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ fun RibWorkerSelectionView(

AddButton(
eventStream,
RibWorkerBindTypeClickType.BIND_MULTIPLE_WORKERS,
"Bind multiple workers",
RibWorkerBindTypeClickType.BIND_MULTIPLE_DEPRECATED_WORKERS,
"Bind multiple Deprecated Workers",
)

AddButton(
eventStream,
RibWorkerBindTypeClickType.BIND_MULTIPLE_RIB_COROUTINE_WORKERS,
"Bind multiple RibCoroutineWorkers",
)

AddButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ public fun CoroutineScope.bind(
return BindWorkerHandleImpl(bindJob, unbindJob)
}

/** Binds [workers] in a scope that is a child of the [CoroutineScope] receiver. */
@JvmOverloads
public fun CoroutineScope.bind(
workers: Iterable<RibCoroutineWorker>,
coroutineContext: CoroutineContext = RibDispatchers.Default,
) {
for (worker in workers) {
bind(worker, coroutineContext)
}
}

/**
* Guarantees to run synchronous [init] block exactly once in an undispatched manner.
*
Expand Down