Search code examples
swiftrx-swiftsubscriber

RXSwift with one time subscriber


I want to subscribe to an observable, but right after the first element, I want to dispose the subscriber.

Is there some default way for that?

If not, how would you solve this? I cannot change the observable, by the way.


Solution

  • just use take operator :)

    yourObservable.take(1).subscribe(....