In the code below, I need to free some resources when unsubscribing (where it registers "release").
Observable first = Observable.create(new Observable.OnSubscribe<Object>() { @Override public void call(Subscriber<? super Object> subscriber) { subscriber.add(Subscriptions.create(() -> { log("release"); })); } }).doOnUnsubscribe(() -> log("first")); Observable second = Observable.create(…).doOnUnsubscribe(() -> log("second")); Observable result = first.mergeWith(second).doOnUnsubscribe(() -> log("result")); Subscription subscription = result.subscribe(…); //… subscription.unsubscribe();
But it only records the “result”. The forbidden subscription does not seem to apply to merged child observables. So, how to handle unsubscribing inside the first observable Observable.OnSubscribe?
unsubscribe , : , . , , , , onError onCompleted, 1.x.
unsubscribe
onError
onCompleted
, , using, :
using
Observable.using( () -> "resource", r -> Observable.just(r), r -> System.out.println("Releasing " + r)) .subscribe(System.out::println);
Source: https://habr.com/ru/post/1614116/More articles:self-tuning with lme4-model and missing values - rNo output when running native OS command with Java - javaWindows is missing Python.h - pythonXcode Versioning History History doesn't show files - gitJavascript: protecting global variables - javascriptCL.exe не обнаружен при установке ионного использования npm в Windows 10 - node.jsВложенная авария neo4j без стека - javaReason neo4j IndexOutOfBoundsException for getRelationships () [again] - neo4jHow to download all background images in one go - htmlWhy am I getting an OpenSSL error when trying to connect to the Apple Push Notification Service? - ruby | fooobar.comAll Articles