Objective:
Achieve the retrieval of output data
{ age: 4, name: 'Foo' }
{ age: 7, name: 'Bar' }
and subsequently utilize this output data in the variable list labeled as "PersonList: Person[] = [];"
Challenge:
I have attempted various solutions to implement the output data into the variable PersonList but have been unsuccessful.
Currently, I am unsure how to proceed with this task.
Stackblitz Link:
https://stackblitz.com/edit/ztwnpx?file=index.ts
Thank you!
import { of } from 'rxjs';
import { distinct } from 'rxjs/operators';
interface Person {
age: number,
name: string
}
of<Person>(
{ age: 4, name: 'Foo'},
{ age: 7, name: 'Bar'},
{ age: 5, name: 'Foo'},
).pipe(
distinct((p: Person) => p.name),
)
.subscribe(x => console.log(x));
// displays:
// { age: 4, name: 'Foo' }
// { age: 7, name: 'Bar' }