RxSwift -.subscribe vs .subscribeNext, what's the difference?

What is the difference between these two operators? http://reactivex.io not to mention .subscribeNext at all.

+6
source share
1 answer

In versions of RxSwift older than 3, subscribeNext(_: Value -> ()) was a specialized version of subscribe(_: Event<Value> -> ()) .

subscribe(_:) will be triggered for all cases of the event, namely .next(Value) , .error(Error) and .completed .

subscribeNext will only run for .next(Value) , first unpacking Value .

As with RxSwift 3, subscribeNext now

 func subscribe( onNext: ((Value) -> ())? = nil, onError: ((Error) -> ())? = nil, onCompleted: (() -> ())? = nil, onDisposed: () -> () = nil ) 

The default values ​​are nil, allowing users to call subscribe only with callbacks that interest them.

+11
source

Source: https://habr.com/ru/post/1011956/


All Articles