DEV Community

Discussion on: Best Practices for Node.js Development

Collapse
 
vbarzana profile image
Victor A. Barzana

That's to avoid spaghetti code. You also don't necessarily need to trigger an event if no one needs it. But it's a good practice to trigger it when you need to bind multiple service actions together, for example, think of a user booking one or multiple services, you could send an email, generate an invoice, post a message on slack,... IMHO there should be even one more step in between, fully configurable workflows that people can rely on. But if you don't have such configuration at the user level, you could bind certain actions from different controllers to the global model event bookings:created, updated, destroyed...