Do I have to unsubscribe from completed observable?

前端 未结 2 1666
别跟我提以往
别跟我提以往 2021-01-31 17:23

If an observable completes, do I still have to unsubscribe / dispose (in RxJava2) the observable to remove the Observer (prevent memory leaks) or is this handled internally by R

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 17:59

    Yes you are correct.

    After a stream is terminated ( onComplete / onError has been called ), subscriber unsubscribes automatically. You should be able to test these behaviors using isUnsubscribed() method on the Subscription object.

提交回复
热议问题