hermanbanken / RxFiddle

Visualize your Observables
https://rxfiddle.net
MIT License
162 stars 9 forks source link

TypeError: Function.prototype.toString is not generic #2

Closed besuikerd closed 7 years ago

besuikerd commented 7 years ago

The following code gives an error

function id(x){return x;}

var o1 = Rx.Observable.just(2,3,4)
  .expand(x => Rx.Observable.ofWithScheduler(Rx.Scheduler.async, x * x))
  .take(10)
  .map(id)
  .filter(x => true)
  .map(id)
  .map(id)
  .map(id)
  .map(id)
  .map(id)
  .map(id)

var o2 = Rx.Observable.just(1)
  .map(id)

o1.merge(o2).subscribe()
hermanbanken commented 7 years ago

Solved with 5cee62ef2186236f2eb42d319f981da0188b61dd. And apparently the just method has as second argument a scheduler, so alternatively you could write:

function id(x){return x;}
var o1 = Rx.Observable.ofWithScheduler(Rx.Scheduler.async, 2,3,4)
  .expand(x => Rx.Observable.just(x * x, Rx.Scheduler.async))
  .take(10)
  .map(id)
  .filter(x => true)
  .map(id)
  .map(id)
  .map(id)
  .map(id)
  .map(id)
  .map(id)
var o2 = Rx.Observable.just(1)
  .map(id)
o1.merge(o2).subscribe()

RxFiddle link