1

I am using the RXKotlin combineLatest and I have a multiple source. but I am calling this like

Observables.combineLatest(source1, source2)
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        {
            val first = it.first
            val second = it.second
        },
        {

        }
    )

and

Observables.combineLatest(source3, source4)
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        {
            val first = it.first
            val second = it.second
        },
        {

        }
    )

now I just want to ask on how to use the combineLatest to my sources only once.

like this.

Observables.combineLatest(source1, source2, source3, source4)
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        {
            val first = it.first
            val second = it.second
            val third = it.third
            val fourth = it.fourth
            //...
        },
        {

        }
    )

I am always using this combineLatest but only with three parameters and I really don't know how or what should I do when I add more parameters to it.

Any help is appreciated, Thank you.

dotGitignore
  • 1,597
  • 2
  • 15
  • 34
  • Since my question marked as duplicate, I just want to clarify if the `Observables` from rxkotlin is the same to `Observable` from rxjava? because the source did not solve my problem. Thanks. – dotGitignore Mar 31 '19 at 04:50
  • hi i have given answer to your question in kotlin. please refer answer by "android". please refer https://stackoverflow.com/a/55438361/7326905 – android Mar 31 '19 at 06:12

0 Answers0