Skip to content

Instantly share code, notes, and snippets.

@webia1
Forked from LironHazan/preventDDOS.ts
Created January 26, 2022 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webia1/0e8ef96c37c0c77bce7a3f4383f3c90e to your computer and use it in GitHub Desktop.
Save webia1/0e8ef96c37c0c77bce7a3f4383f3c90e to your computer and use it in GitHub Desktop.
Doron Sever's snippet for rxjs post
private myStream = new Subject();
private myStream$ = this.myStream.asObservable();
ngOnInit() {
// Will only fire after 100 ms.
this.myStream$
.pipe(auditTime(100))
.subscribe(e => console.log('will only fire after 100 miliseconds');
this.myStream.next(); // Fire it once
setTimeout(() => {this.myStream.next();}, 10); // Fire it twice
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment