Kotlin equivalent of JS function.apply or function.call


#1

How I can invoke function and pass parameters as an Array object? Is there kotlin API? (Ok, js backend can doesn't support it, if need, I can implement it).


#2

Currently, there's no API for that, but we could do something about it. We'll need to discuss the particular solution, though, because it may have subtle implications.


#3

Opposite to java we can reference to function, so, the same approach as in JS is expected — any kotlin function should has method

{code}fun call(paramers:Array<Any>){code}

We don’t need equivalent of js function.call method (i.e. parametes as varargs) because “()” must be used in this case. We don’t need pass “this” reference, because it is not needed for callbacks, otherwise it is API related to reflection (not relevant for this topic).


#4

This should be doable rather easily. Please, submit an issue to the tracker. Thanks


#5

BTW, you can currently implement this manually by providing corresponding extensions. And this may even be the right way of implementing this functionality in the end.


#6

How I can provide corresponding extensions? What is type for function? Do you mean TuplesAndFunctionsGenerator?


#7

No, I meant providing the extensions neede manually.