From 05446e69e1d83d8d0516e28e5c4c62124f8d5d92 Mon Sep 17 00:00:00 2001 From: Patrick Steiger Date: Tue, 25 Jul 2023 12:07:36 -0300 Subject: [PATCH] Add `WorkerBinder.bind` overloads that take in an `Iterable`. `List` is not really needed and we restrict the API unnecessarily: all we need is an `Iterable`. For keeping binary compatibility, we also keep the overloads taking in a `List`. --- .../kotlin/com/uber/rib/core/WorkerBinder.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/WorkerBinder.kt b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/WorkerBinder.kt index c035a3f64..d63ae1941 100644 --- a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/WorkerBinder.kt +++ b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/WorkerBinder.kt @@ -83,6 +83,22 @@ public object WorkerBinder { public fun bind( interactor: Interactor<*, *>, workers: List, + ) { + bind(interactor, workers as Iterable) + } + + /** + * Bind workers (i.e. a manager or any other class that needs an interactor lifecycle) to an + * interactor lifecycle events. Use this class into your interactor and call this method on + * attach. + * + * @param interactor The interactor that provides the lifecycle. + * @param workers A list of classes that want to be informed when to start and stop doing work. + */ + @JvmStatic + public fun bind( + interactor: Interactor<*, *>, + workers: Iterable, ) { for (interactorWorker in workers) { bind(interactor, interactorWorker) @@ -119,6 +135,22 @@ public object WorkerBinder { public fun bind( presenter: Presenter, workers: List, + ) { + bind(presenter, workers as Iterable) + } + + /** + * Bind a list of workers (i.e. a manager or any other class that needs a presenter lifecycle) to + * a presenter lifecycle events. Use this class into your presenter and call this method on + * attach. + * + * @param presenter The presenter that provides the lifecycle. + * @param workers A list of classes that want to be informed when to start and stop doing work. + */ + @JvmStatic + public fun bind( + presenter: Presenter, + workers: Iterable, ) { for (worker in workers) { bind(presenter, worker)