Re:Angular 11
by spyke112 on Thursday November 12, 2020 @08:15AM
(#25069473)
Regarding observables, specifically the ones from HttpClient, i always just do a .toPromise(), and use async/await. My rule of thumb is that if i expect a stream of events use observables, but if it's a one of call, like a http request really is, then i use promises. If i need to memoize the data from the request, i do it in a service, and call through that.
[ Parent
| on HN ]
Re:Angular 11
by modernlearner on Thursday November 12, 2020 @11:18AM
(#25071383)
Just ran into this when building a component to display and filter data. It was starting to turn into a monster when trying to use Rx.js and in the end, the code was simpler to understand with multiple for loops and forEach and map/filter calls.
I ended up with a service that doesn't rely on observables.