Search code examples
javascriptrxjs5jsbin

JSBIN Project with RX.Js 5.0.0 Pulling 'Not Defined' Error


When I run a new JSBIN project with the following specifications:

- Utilizing Tabs: JavaScript, Console

- Adding Library: RxJS 5.0.0

And then run the following code block in the JavaScript area:

var observable = Rx.Observable.create(observer => {
  setInterval(() => {
    observer.onNext('This is the output of my async operation');
  }, 2000);
});

observable.subscribe(response => console.log(response));

The preceding code should render the following output in the console area:

"This is the output of my async operation"

Two seconds later, the console area should gain render:

"This is the output of my async operation"

However, I receive the following error:

"error"
-----------------------------
"ReferenceError: Rx is not defined
    at yivicazake.js:3:4
    at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:13926
    at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:10855

This is my first time pulling in RxJS as a library using JSBIN and I'm hoping someone has had experience with this particular error.


Solution

  • I am not sure which exact version of Rxjs beta u r using, I have created a jsbin here its working fine for me http://jsbin.com/henimevepa/edit?html,js,console,output

    Few things here

    - instead of '.onNext' in version 5 its just '.next'
    - You need to subscribe to observer to run it.