Menu

How to break up pipe into smaller pieces to make it understable

Reddit r/angular·u/Putrid-Bookkeeper968·3 days ago
#Rw8l3wpV
#person#error#pipe#question#code
Reading 0:00
15s threshold

I'm very fresh in Angular, so my question can be funny to experts.

Hello everybody. Funny question...

my code is like this:

updatePerson(person: PersonModel) { this.personService.updatePerson(person).pipe( takeUntilDestroyed(this.destroyRef) ).subscribe({ next: () => this.state.update(() => ({ ...this.state(), loading: false, people: this.people().map(p => p.id === person.id ? person : p) })), error: (error) => { console.log(error); this.setError(error); } }) } And question is how to break up this pipe and then subscribe only one element? The goal is to get a simple array of interfaces (PersonModel is an interface), and then to loop through each object and then call the code from subscribe only for one element?. You just ask how did I get code that I can't make simpler - it is from the tutorial. I know more or less how it works, but I can't make it simpler :-)