java - RxJava Subscribe not working -
i have following code -
package com.test.rxjava; import org.reactivestreams.subscriber; import org.reactivestreams.subscription; import io.reactivex.flowable; public class app1 { public static void main(string[] args) { subscriber<integer> subscriber = new subscriber<integer>() { @override public void onsubscribe(subscription s) { } @override public void onnext(integer t) { system.out.printf("entry %d\n", t); } @override public void onerror(throwable t) { system.err.printf("failed process: %s\n", t); } @override public void oncomplete() { system.out.println("done"); } }; flowable.just(123).subscribe(subscriber); } }
i expecting execute code in onnext method.however nothing happens.however if replace last line below code, output.
flowable.just(123).subscribe((t) -> system.out.println(t));
i not sure missing here. is. new rx world , use figure out wrong. in advance!
subscribers must request items. add s.request(long.max_value);
in onsubscribe method, following:
@override public void onsubscribe(subscription s) { s.request(long.max_value); }
Comments
Post a Comment