JSFiddle - React, Tailwind, and code Playground
JavaScript
(function () {
var testUserLastCall;
function testUser() {
if (testUserLastCall) {
console.log('test user was last called %d seconds ago', (Date.now() - testUserLastCall)/1000);
}
testUserLastCall = Date.now();
}
var testUserThrottled = _.throttle(testUser, 10 * 1000, {
'trailing': true
});
var intervalLastCall;
setInterval(function () {
if (intervalLastCall) {
console.log('interval was last called %d seconds ago', (Date.now() - intervalLastCall)/1000);
}
intervalLastCall = Date.now();
testUserThrottled();
}, 1000);
}());