Rx.js,订阅被调用undefined

我正在使用Rx.js将来自AJAX调用的结果stream式传输到多个单元。

但是,在观察者订阅MapObserver的时候,我遇到了更多的问题。 当第一个用户将总是得到正确的数据,但其余的将不明确。

this.observable = new Rx.Subject(); observeMap = this.observable .map(createMarker.bind(this)); var s1 = observeMap.subscribe(console.log.bind(console, 1)); var s2 = observeMap.subscribe(console.log.bind(console, 2)); 

控制台日志 请指教,谢谢!

我刚刚为我的问题find了一个解决scheme,为了在几个订阅者之间共享一个可观察对象,可以使用share方法。

 this.observable = new Rx.Subject(); observeMap = this.observable .map(createMarker.bind(this)) .share(); var s1 = observeMap.subscribe(console.log.bind(console, 1)); var s2 = observeMap.subscribe(console.log.bind(console, 2));