Changes between Initial Version and Version 1 of Ticket #12451


Ignore:
Timestamp:
Mar 16, 2011, 1:41:23 PM (9 years ago)
Author:
ben hockey
Comment:

tried to fix formatting of description

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12451 – Description

    initial v1  
    1 This is proposal for some rework of event handling. Here are the main improvements/ideas:
     1This is a proposal for some rework of event handling. Here are the main improvements/ideas:
    22
    3 * Uses has() branching
    4 * Function event types, allowing you to create new custom/extension
    5 events (like dojo/touch.press) in a safe extensible way. Special
    6 handling of certain key events (keypress, onmouseleave, and onmousenter)
    7 are implemented using extension events. For example:
    8 dojo.connect(node, dojo.touch.press, listener);
    9 * Introduce a new lightweight dojo/listen module/function that can be
    10 used sans the large blocks of corrective code for keypress,
    11 onmouseleave, and onmousenter emulation (particular useful to avoid for
    12 mobile apps).
    13 * Modularization - Trying to improve the modularity of our event handling:
    14 There is several distinct pieces of functionality in dojo/_base/event.js
    15 that is broken out:
    16 - keypress handling - this is moved out to dojo/_base/keypress.js as a
    17 custom extension/emulation event.
    18 - mouseenter/mouseleave handling - moved to dojo/mouse.js as a custom
    19 extension/emulation event.
    20 - aop - Used for listening to regular object's methods, can be used on
    21 its own, but leveraged by listen module (dojo/aop)
    22 - listen - The main listening component, this does not do include
    23 special code for specific events, but it does include the IE event
    24 normalization code.
    25 - connect - Back-compatible delegation to the other modules, if you look
    26 in connect.js you will see how it does the magical mapping of named
    27 events to these custom events
    28 Note that some of these ideas for aop/listening have been suggesting for
    29 2.0. However, this patch adds this functionality without breaking
    30 compatibility, so it seems like it might be viable in 1.x.
    31 * NodeList.prototype.on() maps to listen() function -
    32 dojo.query(".class").on("some-event", callback);
    33 * Return value from connect() and listen()/on() is an object with three
    34 methods:  cancel(), pause(), and resume()
    35 dojo.disconnect(handle) still works, but can do handle.cancel() instead
    36 (as well as pause and resume)
    37 * dojo/listen provides an Evented base class that can be extended for
    38 event emitting objects, providing on() and emit() methods (could be used
    39 by a future widget class hierarchy)
    40 * list provides separation of events and methods. You can have a "start"
    41 method that conditionally triggers a "start" event (mapped to
    42 "onstart"), for example.
     3 * Uses has() branching
     4 * Function event types, allowing you to create new custom/extension events (like dojo/touch.press) in a safe extensible way. Special handling of certain key events (keypress, onmouseleave, and onmousenter) are implemented using extension events. For example
     5    {{{dojo.connect(node, dojo.touch.press, listener);}}}
     6 * Introduce a new lightweight dojo/listen module/function that can be used sans the large blocks of corrective code for keypress, onmouseleave, and onmousenter emulation (particular useful to avoid for mobile apps).
     7 * Modularization - Trying to improve the modularity of our event handling: There is several distinct pieces of functionality in dojo/_base/event.js that is broken out:
     8    - keypress handling - this is moved out to dojo/_base/keypress.js as a custom extension/emulation event.
     9    - mouseenter/mouseleave handling - moved to dojo/mouse.js as a custom extension/emulation event.
     10    - aop - Used for listening to regular object's methods, can be used on its own, but leveraged by listen module (dojo/aop)
     11    - listen - The main listening component, this does not do include special code for specific events, but it does include the IE event normalization code.
     12    - connect - Back-compatible delegation to the other modules, if you look in connect.js you will see how it does the magical mapping of named events to these custom events
     13
     14    Note that some of these ideas for aop/listening have been suggested for 2.0. However, this patch adds this functionality without breaking compatibility, so it seems like it might be viable in 1.x.
     15 * NodeList.prototype.on() maps to listen() function -
     16    {{{dojo.query(".class").on("some-event", callback);}}}
     17 * Return value from connect() and listen()/on() is an object with three methods:  cancel(), pause(), and resume() dojo.disconnect(handle) still works, but can do handle.cancel() instead (as well as pause and resume)
     18 * dojo/listen provides an Evented base class that can be extended for event emitting objects, providing on() and emit() methods (could be used by a future widget class hierarchy)
     19 * listen provides separation of events and methods. You can have a "start" method that conditionally triggers a "start" event (mapped to "onstart"), for example.