Skip to content

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

License

Notifications You must be signed in to change notification settings

joepdooper/callbackhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

callbackhooks

// 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');