Create one-time subscription

后端 未结 6 2343
遇见更好的自我
遇见更好的自我 2020-12-13 01:05

I need to create a subscription to an Observable that is immediately disposed of when it is first called.

Is there something like:

obser         


        
6条回答
  •  无人及你
    2020-12-13 01:53

    If you want to call an Observable only one time, it means you are not going to wait for a stream from it. So using toPromise() instead of subscribe() would be enough in your case as toPromise() doesn't need unsubscription.

提交回复
热议问题