What is the difference between do
operator and map
operator? It seems the same. I'm learning RxSwift.
Please check the marble diagram of do and map.
in addition to what SPatel mentioned,
do: will not modify the emitted elements but rather just pass them through and has no effect on the actual subscription.
whereas
map: transforms each value of a sequence before emitting on the actual subscription
check this for reference: https://medium.com/ios-os-x-development/learn-and-master-️-the-basics-of-rxswift-in-10-minutes-818ea6e0a05b
map
-> is use to convert one stream into another stream.
do
-> is use to perform some action or task on every stream event
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.