The remaining question I have is:

Why are callAsync() and addListener() doing this differently (except perhaps
for historical reasons)?

Wouldn't it be more consistent if both would have a scope parameter?
Of course, this would be a backward-incompatible change ...

Cheers,
Fritz

On Mon, 23 Nov 2009, Fabian Jakobs wrote:

> Hi Tobias,
>
> one solution to your problem is using qx.lang.Function.bind. With this
> function you can create a wrapped version of your method, which always
> executes with the same "this":
>
> callAsyncScoped(qx.lang.Function.bind(handler, this),arg1,arg2,....)
>
> best Fabian
>
>
>> While qooxdoo is hurling towards 1.0 there is this question that is
>> bugging me.
>>
>> I have learned, that using anonymous functions leads to grief when
>> debugging. So instead of
>>
>>   server.callAsync(function(ret,exc,id){
>>      \\ handler code
>>   },arg1,arg2,arg3);
>>
>> I am writing
>>
>>   function handler(ret,exc,id){
>>      \\ handler code
>>   }
>>
>>   server.callAsync(handler,arg1,arg2,arg3);
>>
>> unfortunately handler runs out of scope. I can therefore not
>> access 'this' inside the handler. Unless I pass this into the
>> handler with the var that=this trick.
>>
>> It works fine but it makes it impossible (afaik) to setup handlers
>> as private methods in the object.
>>
>> In other methods like addListener it is possible to pass along the
>> scope the handler should be run in.
>>
>> I would realy like to see a callAsyncScoped call that works similar
>> to addListener:
>>
>>   callAsyncScoped(handler,scope,arg1,arg2,....)
>>
>> cheers
>> tobi
>>
>>
>
>
>

-- 
Oetiker+Partner AG              tel: +41 62 775 9903 (direct)
Fritz Zaucker                        +41 62 775 9900 (switch board)
Aarweg 15                            +41 79 675 0630 (mobile)
CH-4600 Olten                   fax: +41 62 775 9905
Schweiz                         web: www.oetiker.ch

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to