转载

Observable创建

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 {

            }
        });
复制代码

From

Observable.fromArray("a","b").subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {

            }
        });
复制代码

Just

Observable.just("a","b").subscribe(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {

            }
        });
复制代码

Interval

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

            }
        });
复制代码

Range

Observable.range(0,3).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) throws Exception {

            }
        });
复制代码

Repeat

Observable.range(0,3).repeat(2).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) throws Exception {

            }
        });
复制代码
原文  https://juejin.im/post/5d822a4ee51d453bc6480298
正文到此结束
Loading...