Lazy Evaluation and Streaming With NSFastEnumeration
Since Wolf and Michael’s posts, the old
RXMap
that took a second argument as the collection to fold the mapped results into is gone. In its place is anRXMap
which returns an object conforming toNSFastEnumeration
instead of an instance of a collection class.RXMap
is dead; long liveRXMap
![…]
The latter two benefits can be summed up as lazy evaluation and streaming. Enumerating a long chain of maps with a
for(in)
loop will only take as much CPU time and memory as is required for each stage to complete, and the results will be processed as soon as they’re available, rather than waiting for each stage to complete before going on to the next. All this without threads or asynchrony!
It’s tricky to get NSFastEnumeration
right, especially with ARC, but his framework hides much of the messiness—and it sounds like a future version will hide more.