// 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');
-
Notifications
You must be signed in to change notification settings - Fork 0
A lightweight and flexible callback management library for JavaScript. Easily add, organize, and execute callback functions.
License
joepdooper/callbackhooks
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A lightweight and flexible callback management library for JavaScript. Easily add, organize, and execute callback functions.
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published