Transforming and Combining Streams
Use flatMap, merge, combineLatest, and zip.
Working with Streams
In Combine, a publisher emits a stream of values over time. The real power comes from operators that transform and combine these streams into new ones.
This lesson covers the most important transforming and combining operators: flatMap, merge, combineLatest, and zip.
map vs flatMap
map transforms each value into another value. flatMap goes further — it transforms each value into a new publisher and flattens the results into a single stream.
Use flatMap when each input should trigger another async operation.
All lessons in this course
- Transforming and Combining Streams
- Schedulers and Threading
- Error Handling Operators
- Custom Publishers and Subscribers