Im requesting a web service and receiving an observable and loop them to build another array of objects like below.
export interface Seller {
email?:String;
isOnline?:boolean;
name?:String;
}
Angular Component :
sellers: Observable<Seller[]>;
constructor(firestore: AngularFirestore) {
this.sellers = firestore.collection('sellers').valueChanges();
}
getSllers(){
return this.sellers;
}
Using these sellers Observable im creating an array of objects.
getSellerDetails() {
return this.getSllers().pipe(
map(sellers => {
sellers.filter(seller => seller.isOnline == true)
return sellers.map(seller => {
return {
name: seller.name,
isOnline: seller.isOnline,
email: seller.email
}
});
}));
}
And here i want to filter out the sellers only who are having isOnline true. The snippet im having seems not working. What would be the best approach?
Array.filtermethod called on sellers.selleers=sellers.filter(seller => seller.isOnline == true)-a filter of array return a new array but not change the original array-