Last active
February 10, 2017 19:18
-
-
Save tauren/dbc37a3ee1404cb73415cdaa6ccfd65d to your computer and use it in GitHub Desktop.
RxJS websocket issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let candidatesToSend = [] | |
let candidatesReceived = [] | |
let socketSubject = Observable.webSocket({ | |
url: 'wss://...', | |
openObserver: { | |
next: e => { | |
e.currentTarget.binaryType = 'arraybuffer' | |
candidatesToSend.forEach(candidate => { | |
console.log('sending candidate', candidate) | |
socketSubject.next(candidate) | |
}) | |
candidatesToSend = [] | |
} | |
} | |
}) | |
candidatesToSend.push({ candidate: 1 }) | |
candidatesToSend.push({ candidate: 2 }) | |
socketSubject.subscribe({ | |
next: msg => { | |
console.log('received candidate', msg) | |
candidatesReceived.push(msg) | |
} | |
}) | |
socketSubject.next({ candidate: 3 }) | |
socketSubject.unsubscribe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment