Create one-time subscription

后端 未结 6 2351
遇见更好的自我
遇见更好的自我 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

    RxJS has some of the best documentation I've ever come across. Following the bellow link will take you to an exceedingly helpful table mapping use cases to operators. For instance, under the "I want to take the first value" use case are three operators: first, firstOrDefault, and sample.

    Note, if an observable sequence completes with no notifications, then the first operator notifies subscribers with an error while the firstOrDefault operator provides a default value to subscribers.

    operator use case lookup

提交回复
热议问题