Web Development

Should I Use RxJS in My Project?

May 12, 2017

Travis Luong

By Travis Luong

If you’re thinking about using RxJS, you might as well be asking, “Should I use a jump kick in a street fight?” Unless you are Bruce Lee, probably not.

As a disclaimer, I am not an RxJS pro. I only started learning about it a couple of weeks ago. Consider this post a record of my thoughts as I begin to learn about this powerful library.

According to their website, RxJS is a library for composing asynchronous and event-based programs by using observable sequences. I have been researching whether or not this would be a good fit for one of our current projects. 

So, Is It Worth It?

Front-end Dev Lead Elisha and I discuss RxJS in a recent video:

I’ve heard that once your brain gets plugged into the stream everything will begin to make sense and you’ll eventually reach the promised land. But until you reach that point, it’s a dangerous path, as there are many wrong ways to do things. If you have not yet reached RxJS enlightenment, you might fall into such anti-patterns like the nested subscribe pattern or imperative subscription management.

However, if you can avoid these mistakes and learn some of the commonly used operators like map, filter, do, mergeMap, and switchMap, you’ll be in decent shape. It also helps to visualize observables as marbles of events floating down a stream of time. And RxJS provides a multitude of operators to help you manage those streams. So far, I’ve only learned a handful, but they were enough to get a simple photo search dropdown working with infinite scroll, http cancellation, and debounced input.

So that brings us to the original question.

Should I Use RxJS in My Project?

Well, like many other questions, the answer is: It depends. Do you have the time and budget to learn this new tool which is known to have a steep learning curve? Will your project have complex async requirements that RxJS may bring clarity to? Are you using Angular2, which comes with RxJS out of the box? Will your current framework and lodash suffice for your needs? After reading numerous articles, watching tutorial videos, and building a simple proof of concept, I came to the conclusion that, while RxJS could make my life easier, time spent learning RxJS would add up to unnecessary overhead for a typical CRUD web app project.

RxJS is indeed a powerful tool, and I have only begun to see its potential. I may revisit this library in the future, but, for now, I haven’t encountered a project where the efficiency benefits outweigh the the cost of learning and implementing it.

Travis Luong

Travis Luong

You might also like...

7

Feb.

Jeff Dance

10 Factors for Choosing a CMS

There are dozens of Content Management System (CMS) platforms available to to help you manage the content, marketing, and SEO on your website. But with all the good options out there, how do you know how to choose the right CMS? Consider the following 10 factors when choosing your CMS. #1 Price Some CMS licenses start … Continued

4

Jan.

Ben Spencer

You’ve Beaten B.O.C.O. – Now, Deliver Your Product to the World

Over the course of 2018, Fresh’s designers and developers created an interactive digital journey to educate companies and teams on the UX Design Process. In the research, design, and test worlds, users undertook an adventure to beat B.O.C.O., or “The Beast of Conflicting Opinions.” The beginning of 2019 sees B.O.C.O. defeated at last. Now, you … Continued

25

Apr.

Travis Luong

How to Create a Fuzzy Search-as-You-Type Feature with Elasticsearch and Django

Tutorial: How to Create a Fuzzy Search-as-you-type Feature with Elasticsearch and Django Recently, I had to figure out how to implement a fuzzy search-as-you-type feature for one of our Django web APIs. I couldn’t find any comprehensive tutorial on how to build this specific feature, so I decided to combine multiple sources and document the … Continued