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:
- Usefulness of the package. Do you see this package having any real-world applications in your work?
- External API. Is the API clear and easy to use?
- Documentation. Is the README clear and concise?
- (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!
Latest comments (2)
First view looks great.
Any plan to bring redis or multi-server event management into this? So I can declare a job on one server, and dispatch it from another server. Maybe that's not even related to your initial goal for this project :D .
Thanks. Interesting suggestion. No plans yet, but I'll certainly consider it if there's demand (or I'm bored :D )