java-ddp-client icon indicating copy to clipboard operation
java-ddp-client copied to clipboard

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

Open sornii opened this issue 7 years ago • 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"}

sornii avatar Aug 30 '17 20:08 sornii

@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.

sornii avatar Aug 30 '17 20:08 sornii

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 :-)

kenyee avatar Aug 31 '17 20:08 kenyee