Skip to content

Extension function for List<Single<T>> to Single<List<T>> #207

@tttcowan

Description

@tttcowan

Would there be an interest in having something along the lines of the below in the project? It's just an extension for converting List<Single> to Single<List> via an extension function. There could even be a better way of doing this with Rx but I'm yet to find one. Obvs you could do this for types other than Single as well.

fun <T> List<Single<T>>.zipSingles(): Single<List<T>> {
    if (this.isEmpty()) return Single.just(emptyList())
    return Single.zip(this) {
        @Suppress("UNCHECKED_CAST")
        return@zip (it as Array<T>).toList()
    }
}

Activity

changed the title [-]Extension function for List<Single<T>> and others?[/-] [+]Extension function for List<Single<T>> to Single<List<T>>[/+] on Jan 13, 2019
Korpen

Korpen commented on Oct 17, 2019

@Korpen

Implemented in PR #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tttcowan@Korpen

        Issue actions

          Extension function for List<Single<T>> to Single<List<T>> · Issue #207 · ReactiveX/RxKotlin