Skip to content

Instantly share code, notes, and snippets.

@andrewarosario
Created March 13, 2021 20:37
Show Gist options
  • Save andrewarosario/8c3a877280811f8431cbc8d5579a9645 to your computer and use it in GitHub Desktop.
Save andrewarosario/8c3a877280811f8431cbc8d5579a9645 to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-todo-list',
templateUrl: './todo-list.component.html',
styleUrls: ['./todo-list.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TodoListComponent implements OnInit {
public todos$: Observable<Todo[]>;
public searchForm = new FormControl('');
constructor(private todoService: TodoService) {}
ngOnInit(): void {
this.todos$ = this.searchForm.valueChanges.pipe(
distinctUntilChanged(),
debounceTime(300),
switchMap(search => this.todoService.getTodos(search))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment