0

I am just starting to learn RxJS when I came across two different definitions of Observable:

  1. https://reactivex.io/rxjs/class/es6/Observable.js~Observable.html
  2. https://rxjs.dev/api/index/class/Observable

Which one is legitimate?

JeffC
  • 22,180
  • 5
  • 32
  • 55
rejkid
  • 65
  • 8
  • 1
    They are the same definition. Please point out the differences you've observed. Also, please provide proper links to ensure we are seeing what you are seeing. – Randy Casburn Jan 18 '22 at 23:35
  • Links are: http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html and the other is https://rxjs.dev/api/index/class/Observable. They are completely different. For example the http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html has got dozen of methods and the https://rxjs.dev/api/index/class/Observable has only 5. – rejkid Jan 18 '22 at 23:50

2 Answers2

1

I guess that the first one seems to be an old implementation of the RxJs Observable.

In that page itself, if you click on the RxJs nav "HOME", it says "Rediring to newer docs" and navigates to the second one version.

  • So new Observable (rxjs.dev/api/index/class/Observable) has only 5 methods ? Where are the rest of them (e.g. subscribe) – rejkid Jan 19 '22 at 00:47
  • They are decoupled from the Observable class itself (like it was in old versions). Now you have to import all operators (https://rxjs.dev/guide/operators) and use them inside the `.pipe` function (that is part of Observable) – Jonathan Stellwag Jan 19 '22 at 02:28
  • But where is for example operator 'just' defined. The new implementation seems to be missing some stuff. Janusz – rejkid Jan 19 '22 at 02:50
  • @rejkid: https://stackoverflow.com/a/39427007/6513921 – ruth Jan 19 '22 at 08:50
0

It’s good that you are digging through the source code. Take a look at the npm package “rxjs-compat” this contains additional information about migrating from the previous version of rxjs to the latest version. To be more direct the actual implementation of rxjs observable is different compared to previous versions rather the approach that you would take to require vs import Observable then used to instantiate observables has slightly changed. Fundamentally observables in previous versions and the new version are the same but looking at old code may be confusing in the context of the latest version. Focus on the latest version and take a look at articles or presentations by Ben Lesh if you want to learn RxJS intricacies.