onNext is not getting called on just operator

2019-03-05 08:51发布

I am using rxjava in eclipse. I cretaed the below posted example. the issue is,, when i run the code, I receive only

onSubscribe: 0

and I dont receive any output from onNext.

please let me know why I do not receive any output from onNext, and how to fix it

code:

public static void main(String[] args) {
    Observable<String> stringObservable = Observable.just("Hello from just Operator1");
    stringObservable
    .subscribeOn(Schedulers.newThread())
    .observeOn(Schedulers.io())
    .subscribe(new Observer<Object>() {

        @Override
        public void onComplete() {
            // TODO Auto-generated method stub
            System.out.println("onComplete: OK");
        }

        @Override
        public void onError(Throwable arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onNext(Object arg0) {
            // TODO Auto-generated method stub
            System.out.println("onNext: " + (String) arg0);
        }

        @Override
        public void onSubscribe(Disposable arg0) {
            // TODO Auto-generated method stub
            System.out.println("onSubscribe: " + arg0);
        }
    });
}

0条回答
登录 后发表回答