Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Poll = function(interval) {
- var timers = {};
- function _Poll(interval) {
- console.log('_Poll called with interval', interval);
- console.log('timers is', timers);
- if(!_.has(timers, interval)) {
- timers[interval] = window.setInterval(function() {
- Session.set('_timer_' + interval, Date.now());
- }, interval * 1000);
- }
- return Session.get('_timer_' + interval);
- }
- return _Poll(interval);
- };
- // I want to be able to use it like this...
- Poll(10);
- Poll(20);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement