0
我想了解如何取消訂閱從活動訂閱源創建的Observable。 這裏或多或少代碼:如何取消訂閱實時流
SomeFeed feed = new SomeFeed();
Observable<PriceTick> observable = Observable.create(s ->
feed.register(new SomeListener() {
@Override
public void priceTick(PriceTick event) {
s.onNext(event);
}
@Override
public void error(Throwable throwable) {
s.onError(throwable);
}
})
);
Subscription subscription = observable.subscribe(System.out::println);
subscription.unsubscribe();
System.out.println("Is unsubscribed:" + subscription.isUnsubscribed()); // prints true
我發現後認購退訂是,用戶仍然輸出事件流。
如何取消訂閱以刪除訂閱者接收更多通知?