Event based JavaScript for the browser with comprehensive event management API
91
Build a simple notification dispatcher that manages and triggers notifications for a user dashboard.
Create a notification system that:
Implement a NotificationDispatcher class with the following capabilities:
class NotificationDispatcher {
/**
* Subscribe a handler function to a notification type
* @param {string} type - The notification type (e.g., "info", "warning", "error")
* @param {Function} handler - The function to call when this notification type is triggered
*/
subscribe(type, handler) {
// Implementation here
}
/**
* Trigger a notification of a specific type with data
* @param {string} type - The notification type to trigger
* @param {...*} args - Arguments to pass to the handlers
*/
notify(type, ...args) {
// Implementation here
}
}
module.exports = { NotificationDispatcher };Provides event management capabilities.
Install with Tessl CLI
npx tessl i tessl/npm-wolfy87-eventemitterdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10