[TYPO3-core] RFC #13313: ExtDirect API

Thomas Allmer at at delusionworld.com
Tue Jan 26 11:38:02 CET 2010


On 26.01.2010 10:35, Sebastian Kurfürst wrote:
> Hey Steffen,
>
>>>> 3) Reflection is used to get number of parameters. Why, for what usage?
>>>> Reflection is very expansive call and should be used seldomly.
>>> Do you have another way to get the number of parameters for a method?
>>> The client-side needs the number of parameters to build the stubs
>>> correctly.
>> i don't get it, what do you mean with "build the stubs" ?
>> For client side JS don't need to define all args in function. Also if
>> you code the functions you'd know how many args you use.
>> Maybe you can give a short example?
> OK; If you have a server side class:
> class Foo {
> 	public function bar($argument1, $argument2) {...}
> }
> which is available under "TYPO3.Foo" in JavaScript, you can effectively
> write:
> TYPO3.Foo.bar("arg1", "arg2");
>
> If you want to use a value which is returned, you need to specify a
> callback function (in JS) as last parameter, as Ext.Direct is asynchronous:
> TYPO3.Foo.bar("arg1", "arg2", function() {... do something after the
> method returned ...});
>
> And for that to work, Ext.Direct (on the client side) *must* know the
> number of arguments a function has. Thus, we need to provide it ;)

why not use an argumentarray?

TYPO3.Foo.bar( argumentarray, callbackfunction );


could be used like

TYPO3.Foo.bar(['arg1', 'arg2']);

-- 
+---------------------------------+-----------------------------------+
| Thomas Allmer                   |   http://www.delusionworld.com    |
| E-mail: at at delusionworld.com    |   phone: +43 699 16217064         |
+---------------------------------+-----------------------------------+


More information about the TYPO3-team-core mailing list