I am currently new to RxSwift and I am a little bit confused about the flatMap and merge operator. I know the merge operator merges more than one observable into a single observable. I feel that flatMap is doing the same thing.Am I wrong? If so what is the difference between both
The merge
operator and flatMap
both merge the output of several observables into one observable. The difference is in where the observables being merged come from.
For the merge
operator, there must be a static number of observables already in existence (for the static merge method) or a sequence of observables that are emitted together (for the non-static merge method).
For the flatMap
operator, the observables that are being merged are generated dynamically by the closure passed to the operator.