Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active October 19, 2018 21:12
Show Gist options
  • Save LayZeeDK/813bdb79c2784778bf2488ac337f611b to your computer and use it in GitHub Desktop.
Save LayZeeDK/813bdb79c2784778bf2488ac337f611b to your computer and use it in GitHub Desktop.
Debounced, distinct search presenter
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
export class SearchPresenter {
private _searchQuery: Subject<string> = new Subject();
searchQuery: Observable<string> = this._searchQuery.pipe(
debounceTime(150),
distinctUntilChanged(),
);
search(query: string): void {
this._searchQuery.next(query);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment