An open API service indexing awesome lists of open source software.

https://github.com/joepdooper/callbackhooks

A lightweight and flexible callback utility for JavaScript. Easily add, organize, and execute callback functions.
https://github.com/joepdooper/callbackhooks

async-callback callback callbacks custom-callback event event-driven event-handling events function-hooks hook hooks javascript

Last synced: about 1 month ago
JSON representation

A lightweight and flexible callback utility for JavaScript. Easily add, organize, and execute callback functions.

Awesome Lists containing this project

README

        

# callbackhooks

```javascript
// Import the CallbackHooks module
import { CallbackHooks } from './callbackhooks.js';

// Add a callback to an event named 'userLogin'
CallbackHooks.add('userLogin', function(userData) {
console.log('User logged in:', userData);
});

// Add a callback to an event named 'userLogout'
CallbackHooks.add('userLogout', function() {
console.log('User logged out');
});

// Call the 'userLogin' event with some parameters (user data)
CallbackHooks.call('userLogin', { name: 'Joe', age: 30 });

// Call the 'userLogout' event (no parameters needed)
CallbackHooks.call('userLogout');
```