[dojo-contributors] Initial shape of dojo.touch + dojo.gesture - changes for next patch

Kris Zyp kzyp at dojotoolkit.org
Fri Mar 11 11:41:43 EST 2011


On 3/11/2011 9:30 AM, Evan Huang wrote:
> On Fri, Mar 11, 2011 at 9:47 PM, Kris Zyp <kzyp at dojotoolkit.org> wrote:
>> Thinking more about this... the side-effect based approach of adding new
>> events to dojo.connect, and effectively modifying it's behavior feels
>> less than ideal to me. Modules should avoid modifying other modules if
>> possible. As Bill mentioned, the behavior of dojo.connect shouldn't
>> depend on which modules have been loaded (which may not be visible at
> How about thinking in this way - we make the base of touch & gesture
> oob available and loaded by default - either through the
> dojo/_base/event.js or other ways, making sure the extra code size
> ideally small. The only thing done across widgets would be requiring
> various gesture impl(singleton). e.g. dojo.gestures.Tap/Swipe -
> requiring gesture impl doesn't change the behavior of dojo.connect(),
> but only registering new gesture events that's actually similar as
> loading plugins on demand.

I'd like to avoid increasing the size of base, and as noted in the
granular dependency list, I'd also like to pave the way for base-less
builds where dependencies are more explicit. Either way, we should not
assume the presence of dojo/touch or dojo/gesture or any user custom events.
>
>> all within a module's context). What if someone else creates a "tap"
>> event and it collides with dojo.gesture's? Maybe there is a better way
>> of extending dojo.connect.
> Agree,  need some more thoughts on this. BTW, they can still customize
> the "tap" gesture behavior by overriding the default
> dojo.gestures.Tap?
By monkey patching dojo.gestures.Tap or creating a new one and
overriding "tap" (also a monkey patch)? Either way, this type of
patching is what I am leery of.
>> How about we add support to dojo.connect to take a function as the
>> "event" argument (the second parameter in dojo.connect, first in
>> Nodelist.connect, etc.)? When dojo.connect is called with the "event"
>> argument as a function, it will simply delegate to that function,
>> calling it with the target/obj and callback function as arguments. Then
>> one can use dojo.touch like:
>> dojo.connect(n, dojo.touch.start, callback);
>> or
>> dojo.connect(n, dojo.touch.press, callback);
>> and
>> dojo.connect(n, dojo.gesture.swipe, callback);
>>
>> This produces no unexpected side effects, and is a system that is highly
>> extensible for any third-party/end-user to create new events without
>> conflict.
> Interesting idea :-)  I suppose within dojo.touch.press we still do
> the routine dojo.connect()?

Yes, definitely.
Kris


More information about the dojo-contributors mailing list