Simple event management in JavaScript using eventful

Tue, 10 July 2018

eventful.js
var eventful = {
    on: function(trigger, callback) {
        return window.addEventListener(trigger, callback);
    },
    call: function(trigger) {
        return window.dispatchEvent(new Event(trigger));
    }
}
example.html
<script>
eventful.on('foo', function(e){
    alert('Called foo');
});
eventful.call('foo');
</script>