Hello
Could somebody tell me how to find out what’s the right order of callback parameters for some functions?
I’ll provide an example.
For submitting form there is example piece of code:
Template.body.events({
"submit .new-task": function (event) {
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
var text = event.target.text.value;
As you can see callback function has one parameter called “event”. I’ve seen also two parameters where second one was for template etc.
My question is: Why is every-time “event” first and then “template” and so on? How can i figure out what’s correct order for this callback function and that first parameter will return event, second template and if there is some trhird parameter???
Another example:
if (Meteor.isServer) {
exec = Npm.require('child_process').exec;
Fiber = Npm.require('fibers');
_execSync = function(cmd, stdoutHandler, stderrHandler) {
exec(cmd, Meteor.bindEnvironment(
function(error, stdout, stderr) {
if (stdout != "")
stdoutHandler(stdout);
if (stderr != "")
stderrHandler(stderr);
}
)
);
}
Callback for function “execSync” has 3 parameters. How do I know that first belongs to “cmd” or “error” or something else and second is stdout and not stderr and so on?
Thank you