RxJs Select or Map by ThinqLinq

RxJs Select or Map

While reviewing the recent updates to RxJs and looking at some of the tutorial information, I started to get perplexed at the difference between select or map, selectMany or flatMap, and where or filter. I’ve typically used the LINQ/SQL methods of select, selectMany and where, but while reading the learnrx tutorial I noticed he was using map, flatMap, and filter and became confused as to how these are related. A quick peek at the source (which is easy with JavaScript libraries) reveals how. Here’s the signature of select and map for example:

observableProto.select = observableProto.map = function (selector, thisArg) {
    // Do amazing stuff       
};
So we can see that select and map both extend the Observable prototype and alias the same function. The same is true of selectMany/flatMap and where/filter. As a result, which should you use? It doesn’t matter. Use the syntax that you’re more comfortable with. As a LINQ guy who started with Access in my professional career, I thinq I’ll probably stick to the SQL like methods, but don’t be surprised to see map/filter sneak in from time to time.
Posted on - Comment
Categories: RxJs -
comments powered by Disqus