dojo-core/on
provides event handling support with methods to attach and emit events.
import { emit } from 'src/on';
var button = document.getElementById('button');
var DOMEventObject = {
type: 'click',
bubbles: true,
cancelable: true
};
emit(button, DOMEventObject);
import { on } from 'src/on';
var button = document.getElementById('button');
on(button, 'click', function (event) {
console.log(event.target.id);
});
import { once } from 'src/on';
var button = document.getElementById('button');
once(button, 'click', function (event) {
console.log(event.target.id);
console.log('this event has been removed')
});
import { pausable } from 'src/on';
var button = document.getElementById('button');
var buttonClickHandle = pausable(button, 'click', function (event) {
console.log(event.target.id);
});
buttonClickHandle.pause(); // when paused the event will not fire
buttonClickHandle.resume(); // after resuming the event will begin to fire again if triggered