Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created October 13, 2020 17:04
Show Gist options
  • Save LironHazan/044b126dec1760e2f60be98df647126c to your computer and use it in GitHub Desktop.
Save LironHazan/044b126dec1760e2f60be98df647126c to your computer and use it in GitHub Desktop.

Revisions

  1. LironHazan created this gist Oct 13, 2020.
    13 changes: 13 additions & 0 deletions preventDDOS.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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
    }