I have a child component that receives data via @Input() from parent component (array of objects). I map that data and push object in new array for each object from Input data array in ngOnChanges hook. My goal is to prevent duplicates objects being pushed in new array. Every time ngOnChanges fires new objects are being pushed to admins array. I've tried to use some method in if statement but it didn't help. Here is my OnChanges hook:
ngOnChanges() {
this.adminsGroup.map(a => {
this.authService.getSpecUser(a.user).subscribe(
data => {
data.position = a.permissions;
this.admins.push(data);
}
)
});
}
So I want to ensure that there is no data already in this.admins array before pushing it. Any help would be appreciated.