RxJava icon indicating copy to clipboard operation
RxJava copied to clipboard

how to use Action2-Action9?

Open shen0834 opened this issue 11 years ago • 3 comments

like this , Action2<Integer,String> action2= (i,.s) ->{ System.out.println(i); System.out.println(s); } ,how to subscribe this Action2?
Observable.just(2,"test").subscribe( ) ,this only Action1

I want to pass two or three different argument,how can i do this?

shen0834 avatar Jun 10 '15 09:06 shen0834

You can't do that in RxJava. There are projects that experiment multi-valued Observables: https://github.com/stealthcode/RxJavaMulti for example.

akarnokd avatar Jun 23 '15 07:06 akarnokd

I don't know exactly what you are after but you could also do this:

Observable.just(1, "hello", 2, "there")
    .buffer(2)
    .subscribe(list -> { doSomethingWithTheList(list);});

The lambda is Action1<List<Object>>.

davidmoten avatar Jun 23 '15 08:06 davidmoten

I think the question was answered. Closing.

akarnokd avatar Aug 13 '15 00:08 akarnokd