Meet Burns: cleaner application events for Node.js

Hi dev,to community,

I recently published a new version of my NPM package,Burns. Burns is a Node module for writing clean event-driven code and managing your application events easily. It was inspired by Laravel's events and broadcasting systems.

Here's a brief overview of how you use it:

  • First, you define an event handler:
// handlers/order.js

function sendOrderShippedEmail(data)
{
    mailer.sendEmail(`Hi ${data.userName}, Your order ${data.orderId} has been shipped`);
}
  • Then you attach the handler to an event:
let orderHandlers = require('./handlers/order');
burns.registerEvents({
  orderShipped: orderHandlers.sendOrderShippedEmail
});
  • And then dispatch the event when you're ready!
burns.dispatch('orderShipped', {
    orderId: order.id, 
    userName: user.name
});

You can also get your event broadcast (for instance, via Pusher by specifying a few options.

Please do check it out and share your opinions. 😊

Some things I'd like feedback on:

  1. Usefulness of the package. Do you see this package having any real-world applications in your work?
  2. External API. Is the API clear and easy to use?
  3. Documentation. Is the README clear and concise?
  4. (Bonus: Code quality. Any bugs or things I should watch out for?)

Also, if you know of any tools out there that provide similar functions, I'd love to hear about them.

Thanks!



I write about my software engineering learnings and experiments. Stay updated with Tentacle: tntcl.app/blog.shalvah.me.

Powered By Swish