@axiljs/events
v0.2.8
Published
AxilJS in-process event bus with pub/sub and wildcard support
Maintainers
Readme
@axiljs/events
In-process event bus with pub/sub, wildcard subscriptions, and decorators.
Part of the AxilJS ecosystem.
Install
npm install @axiljs/eventsUsage
import { EventBus, OnEvent, registerEventHandlers } from '@axiljs/events'
const bus = new EventBus()
class NotificationService {
@OnEvent('user.created')
async onUserCreated(event: any) {
await sendWelcomeEmail(event.payload.email)
}
@OnEvent('order.*')
async onAnyOrder(event: any) { }
}
registerEventHandlers(new NotificationService(), bus)
await bus.emit('user.created', { email: '[email protected]' })Full docs: github.com/SyntaxilitY/AxilJS
