Last active
October 19, 2018 21:12
-
-
Save LayZeeDK/813bdb79c2784778bf2488ac337f611b to your computer and use it in GitHub Desktop.
Debounced, distinct search presenter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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