-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handleEvent support #48
Comments
You can use bind for this. |
You propose new DOM events API, but you break the existing features. And no, I can't using var eventObject = {
handleEventAllEvents: function(e) {
console.log(e, 'all events');
if( e.type == 'click' ) {
// For some point we need handle First keyboard event in another handler
this.handleEvent = this.handlerEventsOnlyKeyboadrEvent;
}
}
, handlerEventsOnlyKeyboadrEvent: function(e) {
// handle First keyboard event
if( "keydown|keyup|input".contains(e.type) ) {
console.log(e, 'first keyboard event')
this.handleEvent = this.handleEventAllEvents;
}
}
};
eventObject.handleEvent = eventObject.handleEventAllEvents;
document.addEventListener("click", eventObject);
document.addEventListener("keydown", eventObject); without var eventObject = {
handleAllEvents: function(e) {
console.log(e, 'all events');
if( e.type == 'click' ) {
// For some point we need handle First keyboard event in another handler
e.currentTarget.off("click", {handler: this.handleAllEvents});
e.currentTarget.on("keydown", {handler: this.handlerOnlyKeyboadrEvent});
}
}
, handlerOnlyKeyboadrEvent: function(e) {
// handle First keyboard event
if( "keydown|keyup|input".contains(e.type) ) {
console.log(e, 'first keyboard event')
e.currentTarget.off("keydown", {handler: this.handlerOnlyKeyboadrEvent});
e.currentTarget.on("click", {handler: this.handleAllEvents});
}
}
};
eventObject.handleAllEvents = eventObject.handleAllEvents.bind(eventObject);
eventObject.handlerOnlyKeyboadrEvent = eventObject.handlerOnlyKeyboadrEvent.bind(eventObject);
document.on("click", {handler: eventObject.handleAllEvents}); I find this very complicated and unusable. Another example of using handleEvent from prototype class eventTargetComponent {
handleEvent(e) {
// handle this
}
public static stopEvents() {
this.prototype.__handleEvent = this.prototype.handleEvent;
this.prototype.handleEvent = null;
}
}
for( let i = 0 ; i < 100 ; i++ ) {
document.addEventListener('application_event', new eventTargetComponent );
}
// preventing event handling
eventTargetComponent.stopEvents(); This is just a proof of concept, do not pay attention to the code. |
If Future will pass
event
object as a first parameter to callbackI suggest this:
EventTarget with DOM Future someway, somehow, should support handleEvent. Right now I can write:
or
or even
In DOMFuture proposal it doesn't even mention the
handleEvent
.I think
event
object should contains a Future/Promise state information.The text was updated successfully, but these errors were encountered: