DEV Community

Discussion on: Simple state management in Angular with only Services and RxJS

Collapse
 
nickamorim profile image
Nick • Edited

First of all, thanks for the article.
Its really great, and certainly expanded my horizons on the use of RxJS.

Just one question, on stack blitz you use toPromise() on the calls to the rest api. This could not also be achieved using observables?

this.todosService.setCompleted(id, isCompleted)
.pipe(take(1))
.subscribe({
next: value => {},
error: err => {
console.error(e);
this.todos[index] = {
...todo,
isCompleted: !isCompleted
}
}
});

I did see that you use it because of async/wait but not understand why.
I'm just trying to understand the difference between the two approaches.

Thanks!