Streams are lazy. They work in the same manner as lazy collections in languages such as Scala and Haskell - if you have an infinite collection, say, the set of all prime numbers, and do a map operation on it, it does not try to eagerly execute an infinite loop. Instead, the mapping is only done when when you actually request any of the elements of the set.
> So, I think a better naming would have been...
Often I like to use past participles as names for stream or signal combinators.
So instead of `map`, `filter`, `fold` -- the names are `mapped`, `filter`, `folded`.
For example, given a stream, `(mapped stream f)` returns a new stream with f mapped over it. It returns a mapped stream.
When working with functional programming, thinking about "doing" is often the wrong approach, because "doing" is often tied to "change of state". Instead, think about translations/transformations from "what I have" to "what I want".
clickStream.map(f) doesn't "do" anything - it takes a stream, and returns another stream that's the result of f applied to each element of clickStream.
So if I do something like: astream = clickStream.map(a) bstream = clickStream.map(b) cstream = clickStream.map(c)
I've created three streams that are each the result of a particular function applied to the elements of an original stream.
Re:An Introduction to Reactive Programming
by mattpodwysocki on Monday June 30, 2014 @04:27PM
(#7967482)
You can try our Learn RxJS tutorial here as well: http://reactive-extensions.github.io/learnrx/
I think the best tutorial for me would have been an article explaining what is going on under the hood. This tutorial does mention this implementation detail but only very briefly.
Anyway, without the tutorial, I wouldn't have realized this, so it was actually helpful. :)