# Introducing “Moka,” a Tool for Delivering Static HTML Page Prototypes
# Introducing “Moka,” a Tool for Delivering Static HTML Page Prototypes by zhangxinxu from https://www.zhangxinxu.com/wordpress/?p=8788 This article may be republished in full. Personal websites with independent domain names do not need permission, but must retain the original a...
Code: Dispatching a CustomEvent
const event = new CustomEvent('show', {
detail: { message: payload, sentAt: new Date().toLocaleTimeString() }
});
window.dispatchEvent(event);
Result
Waiting for an event...
Code: Listening for the Event Payload
window.addEventListener('show', (event) => {
render(event.detail.message, event.detail.sentAt);
});
Event log
No events yet.