I cannot figure out how to use WebSocketSubjects in rxjs v6.x
Here\'s the working HTML/JS for v5.5.6
. The commented out code is my attempt
I got it working with rxjs@6.1.0
. As I suspected, I was just using the version 6 syntax wrong. See working example:
<html>
<head>
<script src="https://unpkg.com/@reactivex/rxjs@6.1.0/dist/global/rxjs.umd.js"></script>
<script>
const { WebSocketSubject } = rxjs.webSocket;
const socket$ = new WebSocketSubject('ws://localhost:8080');
socket$.subscribe(
(data) => console.log(data),
(err) => console.error(err),
() => console.warn('Completed!')
);
socket$.next({
event: 'events',
data: 'test',
});
console.log('here')
</script>
</head>
<body></body>
</html>