-1

Any user (client) making a research on my meteor app would call a meteor method that will send asynchronously results to this client when it founds something ( could be by searching many different external apis for exemple ) and possibly would inject it in a client-side only (none persistent) collection. how ?

1 Answers1

0

From the server methods, you can pass error or results and they don't have to be from a collection.

Inside methods:

methodName: function (arg1, arg2){
    if(arg1 !== 'something'){
        throw new Meteor.Error(400, 'Error text.')
    }

    //do something if there is no error here. You don't have to check if there are no errors here as Meteor doesn't jump to DB actions/return a result if there is an error.
    return 'result you want to show. Could be an object, string, a document from the DB etc.'
}

Your call on the client side

Meteor.call('methodName', arg1, arg2, function (err, res){
    if(err){
        //do something with the err
    } else {
        //do something with the result
    }
});

Next time, please check the documentation before asking something. Cheers.

Luna
  • 1,168
  • 8
  • 17
  • Thanks for your answer, but i think you didn't understand my question. Calling a method on meteor of course its easy... Like i explained, on my case its the client telling the server to start working on something and at the same time listen to server anwsers ( who can be anything, anytime and many times, like socket io ) and add it to the client (=template ). Its asynchronous and its the server calling the client and all of this process have to be specific to a meteor user. Cheers – olivier andrade Aug 05 '16 at 17:06