Web Development

Should I Use RxJS in My Project?

May 12, 2017

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

Full-Stack Developer

Travis is a Full-Stack Developer at Fresh who also loves working out, making game apps, and sourcing good bubble tea. His motto is to appreciate balance in life—and find zen in coding.

You might also like...

25

Apr.

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

12

Apr.

6 Things to Look For in a Web Hosting Provider

People often ask us who we recommend for web hosting. Different needs dictate different solutions but there are some universal requirements which almost always need to be met. We have client sites running on many different hosting providers but rather than discuss specific companies let’s go over what we recommend looking for in a web … Continued

26

Mar.

Why HTTPS Matters

What’s HTTPS? Hypertext Transfer Protocol (HTTP) is the underlying data communication system for the Internet. A simple example of the protocol is when you landed on this page, your browser (e.g. Chrome, Safari, etc.) made an HTTP request to the computer that’s hosting this website, and then the hosting computer sent back an HTTP response … Continued

Pacific Science Center

application maintenance and development

Pacific Science Center

Cisco

mobile development

Cisco

Deloitte

web design, microsite development

Deloitte

Seattle Public Library

ui/ux design, microsite development

Seattle Public Library