RxJava - execute the custom operation when unsubscribing
The following example will show how to perform the custom operation when unsubscribing
1
2
3
4
5
6
7
8
9
10
Service service = new Service();
Observable<String> ob = Observable.create(subscriber -> {
subscriber.onNext("test");
service.register();
subscriber.add(Subscriptions.create(() -> {
// do custom operation
service.unregister();
}));
}
);