Skip to content Skip to sidebar Skip to footer

Exception In Setinterval Callback

I'm getting this error after calling a callback function like so: function callbackInterval(test) { Meteor._debug('Test'); } Meteor.setInterval(callbackInterval(test), 60000);

Solution 1:

You need to pass the setInterval a function reference (name or anonymous function), not call the function.

You want:

functioncallbackInterval(test) {
   Meteor._debug("Test");
}

Meteor.setInterval(function () {
    callbackInterval(test)
}, 60000);

If you didn't need to pass callbackInterval a parameter, you would then be able to call:

Meteor.setInterval(callbackInterval, 60000);

Solution 2:

If still needing, or for those who needs it, the correct way would be:

functioncallbackInterval(test) {
  Meteor._debug("Test");
}
Meteor.setInterval(callbackInterval, 60000);

as the test parameter would be injected on the function, but i don't know if set Interval would receive a parameter...

Solution 3:

You can't set function with parameter as a callback function. Use an anonymous function like this instead:

var callback = function ()  {
   callbackInterval(test)
   Meteor._debug("Test");
}
Meteor.setInterval(callbackInterval, 60000);

Solution 4:

If you want to set the parameter to the call back function

You can call the callback function with Parameter like this

setInterval(function (){
        callbackInterval(test)
 }, 1000);

Post a Comment for "Exception In Setinterval Callback"