On Oct 30, 2:30 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> > The "lost" context is easily "fixed":
>
> > sendState(email, $F('save-comments'),
> > sph.fire.bind(sph).curry(doneEvent));
>
> bind() accepts additional parameters for the function, so you don't
> need the curry:
>
>     sendState(
>         email,
>         $F('save-comments'),
>         sph.fire.bind(sph, doneEvent)
>     );
>
> curry is really just bind without the context param.

Good catch : )

>
> > I'd suggest to simply pass a function as in your first example:
>
> > sendState(email, $F('save-comments'), function()
> > { sph.fire(doneEvent) });
>
> Yes, it's definitely clearer.  The only thing would be if there's a
> lot of data referenced in the context where this is occurring that
> he's trying to avoid involving in a closure.  One of the great things
> about bind and curry is that they help you avoid creating closures
> when you don't want to. :-)

Interesting.
There are usually so many closures created (specially in larger
applications), that I have never considered minimizing their presence.
Have you, by any chance, done any "memory tests" on this, T.J.?

> --
> T.J. Crowder
> tj / crowder software / com
>

[snip]

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to