Search code examples
wakanda

Wakanda callMethod synchronous mode


I'm trying to use callMethod() from a method executed on the server.

In this case, I should be able to call it in synchronous mode. However, through trial and error I have found that in this context (i.e. on the server), the method requires three parameters rather than the two mentioned in the docs.

It requires

  • the first parameter to be a string
  • the second parameter to be an array
  • the third parameter to be an object

I've tried quite a few combinations with these parameters but nothing seems to work. At the same time, Wakanda doesn't throw an error as long as the parameters are in the correct form.

Any ideas would be more than welcome.

TIA


Solution

  • Let's suppose we have two variable, one containing the name of the dataClass and the second the name of the dataClass's method :

    var myDataClass = "User";
    var myMethod = "addUser";
    

    To use the dataClass 'User' and call the method 'addUser' you can do it this way :

    var currentClass = ds.dataClasses[myDataClass];
    currentClass[myMethod]()