I do the authorization operation using RxJava. But I want the operation to be declassified after 10 minutes. How can I set a timer and perform this operation using RxJava? Found docks but it turns out I will need to call it immediately after logging in, which I don’t really like.
1 answer
Try to look in the direction of the operator interval.
Implemented as follows:
Scheduler scheduler = Schedulers.from(Executors.newSingleThreadExecutor()); Observable.interval(UPDATE_TIMEOUT, TimeUnit.SECONDS) .flatMap(/** Здесь отправляешь запрос на разлогин */.retry().subscribeOn(scheduler)) .observeOn(AndroidSchedulers.mainThread()) .subscribe(/** Подписываешься и выполняешь необходимые действия после разлогина */); UPDATE_TIMEOUT - time interval. After a razlogin, you can use a Boolean variable to check whether it is logged out or not, so as not to check again.
|
AlarmManager. - temq