Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tttcowan opened this issue Jan 13, 2019 · 1 comment
Open

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

tttcowan opened this issue Jan 13, 2019 · 1 comment

Comments

@tttcowan
Copy link

tttcowan commented Jan 13, 2019

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()
    }
}
@tttcowan tttcowan changed the title Extension function for List<Single<T>> and others? Extension function for List<Single<T>> to Single<List<T>> Jan 13, 2019
@tttcowan tttcowan reopened this Jan 15, 2019
@Korpen
Copy link

Korpen commented Oct 17, 2019

Implemented in PR #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants