How to traverse the data from an observable and insert into a list?
I would like to put together a list of all the arrays it contains within the Observable that comes from the Cloud Firestore because I need a list of people to display in MatTableDataSource .
export interface Pessoa {
nome: string;
cidade: string;
}
export MyClass {
list_pessoa: Pessoa[] = [];
pessoa: Observable<Pessoa[]>;
constructor(){
// Algo parecido como isso, mas que funcione!
this.pessoa.forEach(v =>{
const d = v.values()
this.list_pessoa.push(d);
})
console.log(this.list_pessoa);
}
}
Output:
list_people [
{'name': 'person1', 'city': 'city1'},
{'name': 'pesssoa2', 'city': 'city2'}
]
- How best to go through the data that is inside the Observable and insert into a list of arrays?