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!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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!