Artur Hellmann
Artur Hellmann

Reputation: 325

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.

Upvotes: 3

Views: 4354

Answers (1)

Tomasz Pikć
Tomasz Pikć

Reputation: 763

just use take operator :)

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

Upvotes: 8

Related Questions