Skip to content

Commit

Permalink
Add WorkerBinder.bind overloads that take in an Iterable.
Browse files Browse the repository at this point in the history
`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`.
  • Loading branch information
psteiger committed Jul 25, 2023
1 parent 2de8f90 commit 05446e6
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ public object WorkerBinder {
public fun bind(
interactor: Interactor<*, *>,
workers: List<Worker>,
) {
bind(interactor, workers as Iterable<Worker>)
}

/**
* 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<Worker>,
) {
for (interactorWorker in workers) {
bind(interactor, interactorWorker)
Expand Down Expand Up @@ -119,6 +135,22 @@ public object WorkerBinder {
public fun bind(
presenter: Presenter,
workers: List<Worker>,
) {
bind(presenter, workers as Iterable<Worker>)
}

/**
* 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<Worker>,
) {
for (worker in workers) {
bind(presenter, worker)
Expand Down

0 comments on commit 05446e6

Please sign in to comment.