Created
March 13, 2021 20:37
-
-
Save andrewarosario/8c3a877280811f8431cbc8d5579a9645 to your computer and use it in GitHub Desktop.
This file contains 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
@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