Hey Rytis,
Curry takes the prebound arguments and pushes them onto the
argument chain first, when the callback is executed the additional
parameters, such as your event object are appended. Your event object
is there, its just the parameters are switched, the event object
should be present as the second parameter and your callback will be
the first. Try using a console.log command inside your listener
method for arguments to identify how the chain is truly being
received.
function(){
console.log("inside listener %o", arguments);
}
On May 5, 8:12 am, kangax <[EMAIL PROTECTED]> wrote:
> Function#curry does left-to-right currying only. You would either need
> to wrap handler in another function or use what is sometimes called
> rcurry [1] (a.k.a right curring):
>
> myElement.observe('click', function(e) {
> myFunction(e, myCallback);
>
> })
>
> [1]http://dev.rubyonrails.org/ticket/9034
>
> - kangax
>
> On May 5, 6:01 am, Rytis Daugirdas <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > Is there a way to bind only certain parameters with curry()? Consider
> > this example:
>
> > function myFunction(event, callback)
> > {
> > // ...
>
> > }
>
> > myElement.observe('click', myFunction.curry(myCallback));
>
> > Basically, I'm trying to "preconfigure" myFunction with myCallback and
> > yet still have the event object available when myFunction is actually
> > executed. The above snippet doesn't do what I want because the event
> > parameter inside myFunction is myCallback instead of the actual click
> > event object. Looking at myFunction.curry(myCallback) declaration it
> > does seem logical that event is bound to myCallback, however, is there
> > a way to bind only certain parameters without having to start with the
> > first one?
>
> > Regards,
> > Rytis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---