From 49ed6ed36988a7d20f7975288edc6773f3b9369a Mon Sep 17 00:00:00 2001 From: Jared Wray Date: Fri, 6 Sep 2024 09:04:04 -0700 Subject: [PATCH] Update README.md --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 09dbf73..fd24dfc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Features - Emit Events via [Emittery](https://npmjs.com/package/emittery) -- Middleware Hooks with data passing +- Async Middleware Hooks for Your Methods - ESM and Nodejs 20+ - Maintained on a regular basis! @@ -33,7 +33,7 @@ class MyClass extends Hookified { } async myMethodEmittingEvent() { - await this.emit('message', 'Hello World'); + await this.emit('message', 'Hello World'); //using Emittery } //with hooks you can pass data in and if they are subscribed via onHook they can modify the data @@ -70,6 +70,30 @@ class MyClass extends Hookified { ## API +Please see the [Emittery](https://npmjs.com/package/emittery) documentation for more information on the event emitter. + +### .onHook(eventName, handler) + +Subscribe to a hook event. + +### .removeHook(eventName) + +Unsubscribe from a hook event. + +### .hook(eventName, ...args) + +Run a hook event. + +### .hooks + +Get all hooks. + +### .getHooks(eventName) + +Get all hooks for an event. + +### .clearHooks(eventName) + ## Development and Testing Hookified is written in TypeScript and tests are written in `vitest`. To run the tests, use the following command: