Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TokenAdvancedFragment 中的 retryWhen 问题 #2

Open
amosbake opened this issue Mar 25, 2016 · 0 comments
Open

TokenAdvancedFragment 中的 retryWhen 问题 #2

amosbake opened this issue Mar 25, 2016 · 0 comments

Comments

@amosbake
Copy link

upload()方法中,为什么要用Observable.just+flatmap才能成功地获取到token呢
如我写的两段用和不用的代码,结果只有使用以上组合的才能成功,直接请求的就会不断打印error.这是为什么呢,求教

   Observable.just(session)
                .flatMap(s1 -> DataManager.getInstance().login(s1))
                .retryWhen(observable ->
                                observable.flatMap(throwable -> {
                                            System.out.println("error");
                                            if (throwable instanceof IllegalAccessException) {
                                                return DataManager.getInstance().getSession().doOnNext(s -> {
                                                    session.setSession(s);
                                                });
                                            }
                                            return Observable.just(throwable);
                                        }
                                )
                )

............................

  DataManager.getInstance().login(session)
                .retryWhen(observable ->
                                observable.flatMap(throwable -> {
                                            System.out.println("error");
                                            if (throwable instanceof IllegalAccessException) {
                                                return DataManager.getInstance().getSession().doOnNext(s -> {
                                                    System.out.println("session error");
                                                    session.setSession(s);
                                                });
                                            }
                                            return Observable.just(throwable);
                                        }
                                )
                )
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant