Deferred methods not bound by default?

2 views
Skip to first unread message

markus espenhain

unread,
Oct 27, 2006, 2:10:01 PM10/27/06
to moch...@googlegroups.com
hi

i tried to do something like this

function f1() {
d = new Deferred();
callLater(0, d.callback, 1);
return d;
}

function f2() {
f1().addCallback(console.log, 'hello from f2');
}

f2();
// nothing happens

... and i noticed that deferred methods are not bound to deferred obj
and that it is done manual, e.g. in MochiKit.Async.wait() -
m.bind("callback", d),

so why deferred methods not bound by default to a deferred instance? -
if there is a reason for that please be so kind to let me know

thanks
markus

Bob Ippolito

unread,
Oct 27, 2006, 3:43:09 PM10/27/06
to markus espenhain, moch...@googlegroups.com

They're not bound by default because methods aren't bound in
JavaScript. To give the illusion of binding there'd be additional
overhead for every Deferred object instantiation and every method
call. MochiKit doesn't change how JavaScript works fundamentally.

-bob

Reply all
Reply to author
Forward
0 new messages