Is it correct to filter the observed array of objects, regardless of whether the specific property for each index is true?

So, I have an observable type Student []. That is, an observable array of objects. The student has a property id: number. How can I filter the indexes of an array of students based on a property. For example, let's say that $ students are observed as type Observable [Student], and I would like to remove the student from Observable<Student[]>based on my "bannedId", I tried:

students$.filter(student => student.id !== bannedId)

however, I got an error that id is not a property of Student []. If I put an index, i.e. student[0].id, it recognizes the property, but obviously will not do what I want. How can I filter this?

+4
source share
1

Observable.map(...)?

students$.map(studentList => studentList.filter(student => student.id !== bannedId))

Observable, , - .

+4

Source: https://habr.com/ru/post/1690354/


All Articles