Preface Rx series of articles

  1. RxJava met
  2. RxJava overview
  3. RxJava operator
  4. Observables create
  5. The Observer’s creation
  6. RxJava various ways to unsubscribe

Create

 Observable.create(new ObservableOnSubscribe<String>() {
            @Override
            public void subscribe(ObservableEmitter<String> emitter) throws Exception {

            }
        }).subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {}});Copy the code

From

  Observable.fromArray("a"."b").subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {}});Copy the code

Just

  Observable.just("a"."b").subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {}});Copy the code

Interval

Observable.interval(1, TimeUnit.SECONDS).subscribe(new Consumer<Long>() {
            @Override
            public void accept(Long integer) throws Exception {}});Copy the code

Range

 Observable.range(0.3).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) throws Exception {}});Copy the code

Repeat

 Observable.range(0.3).repeat(2).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) throws Exception {}});Copy the code