JavaScript — Observables Under The Hood
Netanel Basal

excellent post. I tried ur code. It works. I have 2 questions though.

  1. in the real RxJs Observable, subscribe function takes in 3 parameters: function next(){}, function err(){}, function complete(){}

while in your code sample, it takes in 1 parameter which is an object of

{ next(), err(), complete()}

I tried passing in 3 parameters in your code sample. Of course it throws error because next() is no longer an function in observer. So is your code still representative of the concept of observable?

2. there is a “static” in the fromEvent() method. I tried without it and the code breaks. it throws an error

“testScript.js:61 Uncaught TypeError: Observable.fromEvent is not a function(…)”

I cannot figure out why static is the key in making this work and why other function can do without.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.