Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.49k stars 2.1k forks source link

Multiple subscribers to WebSocketSubject not getting data #1520

Open arikimolloy opened 6 years ago

arikimolloy commented 6 years ago

I'm using RxJS 4 (can't use 5 on this project). If I have multiple subscribers to the subject, only the first one subscribed seems to receive data. Does WebSocketSubject not work well with multiple subscribers?

simplified example:

webSocketSubject = Rx.DOM.fromWebSocket(
                this.url,
                null,
                openObserver,
                closingObserver
            );

webSocketSubject.subscribe(message => console.log('111'));
webSocketSubject.subscribe(message => console.log('222'));

Subscribe will kick off the socket, but only one of the subscribers (ends up being '222') gets data. If I throw a setTimeout around the second subscribe, then '111' will be the one who gets the data.

Thanks for the help.