Skip to content

Instantly share code, notes, and snippets.

@weihungchin
Created May 3, 2021 12:54
Show Gist options
  • Save weihungchin/d79a5ef9284d9dade5386e0415344de9 to your computer and use it in GitHub Desktop.
Save weihungchin/d79a5ef9284d9dade5386e0415344de9 to your computer and use it in GitHub Desktop.
import { tap. retryWhen } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';
import { timer } from 'rxjs';
const wsSubjec2$ = webSocket({
url: 'wss://www.gasnow.org/ws/gasprice',
});
wsSubject$
.pipe(
tap((data) => console.log(data)),
retryWhen((errors) => errors.pipe(delayWhen((val) => timer(val * 1000))))
)
.subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment