LynAs
LynAs

Reputation: 6567

Observable.just Access multiple params

In the following code when I print s I get the first String that is given as the parameter of Observable.just .

Observable.just("Str1","Str2","str3")
    .map(new Func1<String, Object>() {
        @Override
        public Object call(String s) {
            System.out.println(s)
            return "test";
        }
    });

How do I get the rest of the parameters inside call Method ??

Upvotes: 0

Views: 530

Answers (1)

AndroidEx
AndroidEx

Reputation: 15824

Observable.just() will emit the passed arguments one-by-one. You can wrap them in an array or a List to treat them as a single object:

String[] array = new String[] {"Str1", "Str2", "str3"};
Observable.just(array)
          .map(new Func1<String[], Object>() {
              @Override
              public Object call(String[] strings) {
                  return null;
              }
          });

Upvotes: 2

Related Questions