Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active February 18, 2020 02:41
Show Gist options
  • Save alexytiger/b71f69736c8a9b63605aafe72018d330 to your computer and use it in GitHub Desktop.
Save alexytiger/b71f69736c8a9b63605aafe72018d330 to your computer and use it in GitHub Desktop.
e-book
ngAfterViewInit() {
const products$ = this.store$.pipe(select(fromStore.getAllProducts));
const filter$ = fromEvent(this.contractKey.nativeElement, 'keyup').pipe(
map(event => this.contractKey.nativeElement.value),
startWith(''),
debounceTime(150),
distinctUntilChanged());
this.filteredProducts$ = combineLatest([products$, filter$]).pipe(
map(([products, filterString]) =>
products.filter(product =>
product.productKey.indexOf(filterString) !== -1))
);
setTimeout(() => {
this.contractKey.nativeElement.focus();
}, 150);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment