How to use RxJava combineLatest operator with more than 9 observables

前端 未结 6 595
一个人的身影
一个人的身影 2020-12-16 17:25

I\'m using RxJava and I want to combine 12 different observables using the operator combineLatest.

I saw a function prototype that takes a list of obse

6条回答
  •  别那么骄傲
    2020-12-16 17:36

    There is a combineLatest that takes a List of observables. Here's an example on how to use it:

    List> list = Arrays.asList(Observable.just(1), Observable.just("2"));
    Observable.combineLatest(list, new FuncN() {
        @Override
        public String call(Object... args) {
            String concat = "";
            for (Object value : args) {
                if (value instanceof Integer) {
                    concat += (Integer) value;
                } else if (value instanceof String) {
                    concat += (String) value;
                }
            }
            return concat;
        }
    });
    

提交回复
热议问题