I've got an interface that basically lets you add, edit, or delete a user. When the component initializes it does an http request to the server to get current users. So if you go to edit or delete a user there is a dropdown of all the users received from that request. The problem is that if the I delete a user for example through http request, I need to then send another get request to update the data client side so that if you were to open the dropdown again it would reflect the changes made. I can fix this problem by running 'ngOnInit()' again after successful request but this means I'm 'subscribing' every time the user does something..
ngOnInit() {
this.service.getUsers()
.subscribe(payload => {
payload.forEach(user => {
this.users.push(user);
});
});
}
I'm new to Angular so I'm not entirely sure the best way to go about it but I feel like running this method of 'subscribing' every time the user performs a request is wrong. Any help would be appreciated.