The State of Reactive in JS: a practical overview of FRP libraries

    The article was born from this answer on StackOverflow and grew into a blog post ( in English ), but I think it has not lost its relevance.

    Now there is a lot of noise around Reactive Programming. I spent some time studying this discipline applicable to JavaScript and Node.js and made up my mind about the most interesting libraries in my opinion.

    Rxjs


    This is a kind of benchmark - the advent of Reactive Extensions for .net, in a sense, created this discipline.

    Pros:



    Cons:


    • Sometimes it looks like a matan. The documentation resembles the abyss - it is not clear how to pull it all over your head?
    • Implemented by guys with Java in their heads (love of a lot of abstractions, idioms from Java / .Net, sometimes weird signatures). This is not that bad, it’s just that some things look strange in JS (an example of Scheduler - I still don’t understand why all this is needed in a single-thread environment). Hence the desire to write in TypeScript`e

    Bacon.js


    Once a fashionable library for hipsters - now everyone has forgotten

    Pros


    • Good documentation and good examples from the community (for example, the game Snake );
    • Almost all primitives from Rx * are implemented;
    • Realized in the first very for JS and JS with the whole background;
    • IMHO, it is very easy to start just by going through the examples and documentation.

    Cons


    • No backpressure - let's just forget about backend development

    Highland.js


    Library from caolan - Photo by async

    Pros:


    • It was immediately written for JS / Node.js by the guys who wrote something big on them and love the language / platform - which means the JS-idiomat and Node.js in their head (see the next paragraph);
    • Built on top of Node.js Stream , this provided the library with a small size. In addition, subjectively, it’s so much easier to think about it all: we have stream A, we do something with it and pipe it in stream B (here is my article, with an example );
    • backpressure - And as far as I understand, nothing needed to be written by hand, everything is already in Node.js Stream.

    Cons:


    • Weak documentation is already better and lack of examples. For examples you will have to climb into Rx or Bacon - put up with this;
    • Lack of many primitives. Not that they are difficult to implement with your hands, but still. Example .interval and .combineLatest;
    • Very subjective: Phlegmatic communities - they write themselves, they bliss themselves, they do not lead expansion.

    Instead of a total


    Due to the lack of reasonable examples, you will have to look at all these libraries, Rx * so for sure. IMHO, the most correct Highland - the people who wrote it understand the idioms of the platform and love it. The most “mature” RxJS - it was “cut” into Angular yet, hype-guaranteed.

    Hint: If you need to ask something on StackOverflow, immediately translate RxJS- “dialect”, so they are more likely to answer.

    Also popular now: