DEV Community

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

Collapse
 
vladpavliuk profile image
Vlad • Edited

Hi, in the user's code I've noticed, that you pass 'event' to the remove method:
(remove)="todosStore.removeTodo($event)"

Shouldn't it be just an id?:
(remove)="todosStore.removeTodo(todo.id)"

Collapse
 
avatsaev profile image
Aslan Vatsaev

both are correct, if the app-todo-component outputs the todo id in the event, it'll still work

depends on the implementation of the @Ouptut

Collapse
 
vladpavliuk profile image
Vlad

Yea, I completely agree, they are the same, I guess there is a real small advantage to use todo.id instead of $event - if we use todo.id we explicitly say that we wanna to use id property from list of todos, otherwise if we use $event we delegate the responsibility to the child component to use 'remove' event properly (pass the correct value).