DEV Community

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

Collapse
 
fbrun profile image
Fred • Edited

Thanks for this post, it's help us very well.

When you define the "readonly completedTodos$" in the service, you use the getter (this.todos) in the map operator to filter the stream. What doesn't use directly the "todos" var entry from the map operator like this:
readonly completedTodos$ = this.todos$.pipe(
map(todos => todos.filter(todo => todo.isCompleted))
) ?

Collapse
 
avatsaev profile image
Aslan Vatsaev

Hey, both do the same thing, but yes you are correct, using todos from the map makes more sense, i updated the article.