kenyee/java-ddp-client

Ability to use a single object as parameter in methods and subscriptions

sornii opened this issue · 2 comments

Hi,

We have a guide in meteor that suggests to use a single object as a parameter in method calls and subscriptions. Since that, I built every method or subscription this way:

Meteor.methods({
  'iterations.insert'({ uuid, name }) {
    const _iteration = Iterations.findOne({ uuid });
    if (_iteration) {
      return _iteration._id;
    }
    return Iterations.insert({ uuid, name });
  }
});

It's not possible, because the client.call that's implemented in this project receives a array of objects Object[] and pass it as parameters building a json like this:
params: ["uuid", "name"].

It should be possible as well to pass a single object to client.call but I don't know if its going to build this:
params: [{uuid: "uuid", name: "name"}]
or this
params: {uuid: "uuid", name: "name"}

@kenyee I could commit the code, but I don't know how to test it using gradle, never used it in a project as package manager.

Interesting...that must be a new Meteor guide. If it's a client.call with a single object parameter, it'd be an object, so it'd look like this:
{uuid: "uuid", name: "name"}
The other one you had is actually an array of one object....you should be able to do that now using the existing client.call.
Is this common practice? It's the first time I've heard of it :-)