[mochikit] Re: connectEach shortcut

2008-12-14 Thread Amit Mendapara

Look at the MochiKit.Query module of the MochiKit Extensions (http://
launchpad.net/mochikit-ext).
It provides jQuery style signal functions...

MochiKit.Query('#my-ul li').click(function(evt){
   // handle events here
});

or

MochiKit.Query('#my-ul li').click(some_callback);

then you can signal to matched elements by simply calling...

MochiKit.Query('#my-ul li').click();

Regards
--
Amit

On Dec 12, 9:45 pm, Eoghan  wrote:
> I often use the following utility function:
>
>     function connectEach(iterable, signal, dest, func){
>         forEach(iterable, function(el){
>                 connect(el, signal, dest, func);
>             });
>     }
>
> It might be used as follows:
>
>     connectEach($$('#my-ul li'), 'onclick', function(e){
>                 // do sumn'
>          });
>
> rather than slightly more unwieldy:
>     forEach($$('#my-ul li'), function(el){
>             connect(el, 'onclick', function(e){
>                     // do sumn'
>                 });
>          });
>
> Is it a good candidate to include in the Signal api?
>
> Eoghan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to 
mochikit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: connectEach shortcut

2008-12-14 Thread Per Cederberg

I think it is an interesting idea to be able to bind any argument
position. Think I mentioned it earlier in the 1.5 API discussion that
we now have quite a few variants of bind-like functions -- bind,
bindLate, bindMethods, forwardCall, partial, method, methodCaller...

Too many for my taste, so I think it is time to revisit these API:s.
Perhaps something more generic than the current bind() might be a good
idea? Or perhaps it would have an API that is too complex? Don't know
really.

I'll look into the code posted by Arnar later on (no much time right
now) and comment on the specifics then.

Cheers,

/Per

On Sun, Dec 14, 2008 at 1:53 AM, Arnar Birgisson  wrote:
>
> On Sat, Dec 13, 2008 at 23:26, Eoghan  wrote:
>> May I suggest MochiKit.Base.__  as the name of the placeholder
>> variable.
>
> If Bob or Per want to include this, I'd like to change it to make it
> compatible with the current partial (namely, any extra parameters
> passed on the call itself will just be tacked on the end).
>
> MochiKit.Base.__ sounds good to me. Just _ is more likely to step on
> someone's toes.
>
>> I can't imagine needing the permuting version myself.
>
> Actually, 95% of the cases I've wanted this I just wanted flip
> (reverse the order of two parameters). At the very least I'd like to
> see
>
> function flip(f) {
>return function (x,y) { return f(y,x); };
> }
>
> included. In other cases, I have definitely had use for the generic
> permuting version.
>
> cheers,
> Arnar
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to 
mochikit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---