Reputation: 93
According to the Node.js behaviour for 'setTimeout', it "returns a timeoutObject for possible use with clearTimeout(). Optionally you can also pass arguments to the callback".
Is there any way that once a setTimeout is called and a timeoutObject is generated, I can access the arguments passed to the callback using the timeoutObject?
E.g. var timeout = setTimeout(function(a,b) { console.log(a); console.log(b);}, 5000, 'Foo', 'Bar');
I would like to access the arguments passed ('Foo' and 'Bar') using the 'timeout' variable. Any way this can be achieved?
Upvotes: 0
Views: 150
Reputation: 161457
There is not. You could certainly make your own wrapper function that returns a normal object that tracks the timer object and the args though.
Upvotes: 1