I'm struggling to figure the correct way to filter an array of objects using RxJS 6.
Here's the scenario. I have users: User[], filter: FormControl, and another array of filteredUsers: User[]. What I would like to do is filter the list the users based on the value contained in the filter. The only way I was able to figure this out was to use tap, and while this works, it just doesn't seem like the right way to do it...plus the whole list is "filtered out" until the filter control has its first valueChange.
this.filter.valueChanges.pipe(
tap((term) => {
this.filteredUsers = this.users.filter(u => u.name.indexOf(term) != -1)
})).subscribe()
Any help would be greatly appreciated.