Performance: PUT and DELETE requests
MEDIUM IMPACT
This affects the network request time and how quickly the UI updates after data changes.
this.http.put('/api/items/' + id, data).subscribe(() => { this.items = this.items.map(item => item.id === id ? {...item, ...data} : item); }); this.http.delete('/api/items/' + id).subscribe(() => { this.items = this.items.filter(item => item.id !== id); });
this.http.put('/api/items/' + id, data).subscribe(() => { this.loadAllItems(); }); this.http.delete('/api/items/' + id).subscribe(() => { this.loadAllItems(); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Reload all data after PUT/DELETE | Many DOM updates | Multiple reflows | High paint cost | [X] Bad |
| Update local state after PUT/DELETE | Minimal DOM updates | Single reflow | Low paint cost | [OK] Good |