Join Scott Gardner for an in-depth discussion in this video Transform observable sequences, part of Reactive Programming in iOS with RxSwift.
- [Voiceover] When an observable sequence…emits a next event, you will often want to work…with that element usually transforming it…in someay beforehand.…For example, maybe the element is an NSDate instance,…and you want to format it as a string representation…before displaying it in the UI label.…To transform elements emitted from an observable sequence,…you use the map operator.…Map will transform each element as it's emitted…from the source observable sequence.…This is similar to the map method in the…Swift Standard Library, except that this map…works with observable sequence elements.…
I'll create an observable sequence of integers…using the of operator.…And then I'll use the map operator…to multiply each integer element by itself,…and use subscribeNext to print out each transformed element,…and I'll just call dispose…on the return value from subscribeNext.…Remember that subscriptions return the disposable…so that it can sound the warning.…The printed results are what we'd expect.…
What if you have an observable sequence…
Learn reactive programming with Reactive Extensions for Swift and iOS by following along with author Scott Gardner. Scott introduces the Reactive Extensions libraries for Swift and Cocoa Touch, and shows how to work with observable sequences, bind user interface and data elements, perform networking operations, debug Rx code, and more.
- Using the Reactive Extensions library
- Working with observable sequences
- Binding UI and data elements
- Binding table and collection views
- Error handling