The nesting problem of RxJava inverse observable

question:
request the network after RxView.clicks, using retrofit, as follows:

RxView.clicks(findViewById(R.id.button2))
                .subscribe(new Consumer<Unit>() {
                    @Override
                    public void accept(Unit unit) throws Exception {
                        Http.get().create(TimeApi.class).getLicense(TimeApi.url)
                                .subscribeOn(Schedulers.io())
                                .observeOn(AndroidSchedulers.mainThread())
                                .subscribe(new Consumer<TimeModel>() {
                                    @Override
                                    public void accept(TimeModel timeModel) throws Exception {
                                        btn.setText(timeModel.getData() + "");
                                    }
                                }, new Consumer<Throwable>() {
                                    @Override
                                    public void accept(Throwable throwable) throws Exception {

                                    }
                                });
                    }
                });
                

how to eliminate nesting?
I used concatMap and flatMap,compose, and they all had some problems. For example, Scheduler issues, or click events execute directly without clicking:


        ObservableTransformer<Unit, TimeModel> transformer = new ObservableTransformer<Unit, TimeModel>() {

            @Override
            public ObservableSource<TimeModel> apply(Observable upstream) {
                return Http.get().create(TimeApi.class).getLicense(TimeApi.url);
            }
        };

        RxView
                .clicks(btn2)
                .compose(transformer)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<TimeModel>() {
                    @Override
                    public void accept(TimeModel model) throws Exception {
                        Log.d("HHHH", model.getData()+"");
                        btn2.setText(String.valueOf(model.getData()));
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        Log.d("HHHH", "error");
                        btn2.setText("---------------"+throwable.getMessage());
                    }
                });

        RxView.clicks(btn2)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .concatMap(new Function<Unit, ObservableSource<TimeModel>>() {
                    @Override
                    public ObservableSource<TimeModel> apply(Unit unit) throws Exception {
                        return Http.get().create(TimeApi.class).getLicense(TimeApi.url);
                    }
                })
                .subscribe(new Consumer<TimeModel>() {
                    @Override
                    public void accept(TimeModel model) throws Exception {
                        Log.d("HHHH", model.getData()+"");
                        btn2.setText(String.valueOf(model.getData()));
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        Log.d("HHHH", "error");
                        btn2.setText("---------------"+throwable.getMessage());
                    }
                });


        Disposable subscribe = RxView
                .clicks(btn2)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .flatMap(new Function<Unit, ObservableSource<TimeModel>>() {
                    @Override
                    public ObservableSource<TimeModel> apply(Unit unit) throws Exception {
                        Log.d("HHHH", "request");
                        return Http.get().create(TimeApi.class).getLicense(TimeApi.url);
                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<TimeModel>() {
                    @Override
                    public void accept(TimeModel model) throws Exception {
                        Log.d("HHHH", model.getData()+"");
                        btn2.setText(String.valueOf(model.getData()));
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        Log.d("HHHH", "error");
                        btn2.setText("---------------"+throwable.getMessage());
                    }
                });
May.04,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3062d-2bd3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3062d-2bd3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?