-
-
Save stepango/1fde5835eb595148d0d969c6a72ddbde to your computer and use it in GitHub Desktop.
Final example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final PublishSubject<Void> viewClickedSubject = PublishSubject.create(); | |
private final CompositeSubscription startStopCompositeSubscription = new CompositeSubscription(); | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
view.setOnClickListener(v-> viewClickedSubject.onNext(null)); | |
Subscription subscription = viewClickedSubject | |
.throttleFirst(200, TimeUnit.MILLISECONDS) | |
.switchMap(aVoid-> api.getAlert() | |
.retryWhen(RetryWithNetwork.create(context)) | |
.retryWhen(RetryExponetialy.create()) | |
) | |
.subscribe( | |
this::makeAlertToast, | |
throwable -> { | |
throw new OnErrorFailedException(" Unsubscribed from View click events.", throwable); | |
} | |
); | |
startStopCompositeSubscription.add(subscription); | |
} | |
@Override | |
protected void onStop() { | |
super.onStop(); | |
startStopCompositeSubscription.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment