Skip to content

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

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()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions