Reactive Observable Subscription Disposal

前端 未结 4 967
野性不改
野性不改 2020-12-05 10:25

If I have access to an IObservable that I know is only ever going to return one item, will this work and is it the best usage pattern?

IDisposable disposable         


        
4条回答
  •  时光说笑
    2020-12-05 10:56

    Disclaimer: I'm also still learning Rx. So I'm not really an expert but I believe the disposable returned by Subscribe will only unsubscribe the subscription. Also if the source completes, like in your case, the unsubscription is done automatically. So I think the Dispose there is redundant and can be safely removed.

    See the answer to this question for more info.

提交回复
热议问题