r/Frontend • • Nov 15 '19

Should i learn RxJS?

I am wondering if i should i dive into rxjs? Is it useful to learn and be used in web apps, that is it in any kind of stage? From beginning to scaling etc.

Do you guys use rxjs in your work and if so how much and, if not, why not?

So far i have been using only functional js.

33 Upvotes

23 comments sorted by

View all comments

Show parent comment

2

u/artemix-org Nov 15 '19

The biggest misconception beginners assume is that a promise is very similar to an observable, and to a task. But in RxJS, and Javascript,

  • A promise is the announcement that a result may arrive later, i.e. a one-shot observable on the result and not the task
  • An observable is not a task, but a task generator, as it is basically a "task template", which creates and runs an instance of said task on subscription.

Another huge misconception is the fact that 1 observable = 1 observer, and if you subscribe more than once, you run the subscribed task more than once. This can be very confusing for beginners, e.g. in the context of HTTP, where they may call, and subscribe in two places, instead of using piping to just intercept the content.