connect/signal and update from 667 to 1.3.1

0 views
Skip to first unread message

markus espenhain

unread,
Sep 11, 2006, 9:00:14 PM9/11/06
to moch...@googlegroups.com
hi

i'm using MochiKit.Signal for app internal event based communication too
and i've just updated MochiKit sources from rev 667 (something before
1.3 release) to 1.3.1 and to current HEAD but connect(obj, 'asd',
this.doAsd) and signal() doesn't work anymore as expected - doAsd() is
called but 'this' isn't bound to the object which has done the connect
... all objects are calling bindMethods(this) in constructor

any idea?

thanks
markus

ps: connect(obj, 'asd', this, 'doAsd') and signal() works still as expected

Bob Ippolito

unread,
Sep 11, 2006, 9:08:48 PM9/11/06
to markus espenhain, moch...@googlegroups.com
On 9/11/06, markus espenhain <m...@cubeball.net> wrote:
>
> i'm using MochiKit.Signal for app internal event based communication too
> and i've just updated MochiKit sources from rev 667 (something before
> 1.3 release) to 1.3.1 and to current HEAD but connect(obj, 'asd',
> this.doAsd) and signal() doesn't work anymore as expected - doAsd() is
> called but 'this' isn't bound to the object which has done the connect
> ... all objects are calling bindMethods(this) in constructor
>
> any idea?

Could you put together a little example that demonstrates this? If
"this.doAsd" is bound with bindMethods, there's no way that "this" can
change to anything but the object it was originally bound to... so I'm
not sure I really understand where the expectation differs or how it
could've changed across those versions.

-bob

markus espenhain

unread,
Sep 11, 2006, 9:50:16 PM9/11/06
to moch...@googlegroups.com

yes - here it is

A = function() {
bindMethods(this);
};

A.prototype = update({}, {
init: function() {
this.qwe = 123;
this.b = new B();
connect(this.b, 'asd', this.onAsd);
this.b.test();
},

onAsd: function() {
alert(this.qwe) // <- undefined
alert(this.test) // <- func def
}
});

B = function() {
bindMethods(this);
};

B.prototype = update({}, {
test: function() {
signal(this, 'asd');
}
});

new A().init();

it seems that 'this' is bound to signal src that - this.test in onAsd()
is not undefined ... ?

thanks
markus

Reply all
Reply to author
Forward
0 new messages