JS pure front-end implementation for trimming, cutting, copying, playing, and uploading a...
JS pure front-end implementation for trimming, cutting, copying, playing, and uploading audio This article was published on Monday, July 27, 2020, at 23:51, under JS Examples. Here’s the background: users upload audio files, but often only a few dozen seconds are needed. Regular...
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.