Delayed Ajax update [redux]

I figured out that I could use the delayed Ajax update design pattern from yesterday to other things, so I made it possible to delay any function:
var T_TIMEOUTS = {};
function delayAjaxUpdate(id, interval, fn) {
    var time_out = T_TIMEOUTS[id];
    if(time_out)
        clearTimeout(time_out);
    T_TIMEOUTS[id] = setTimeout(fn, interval);
}

How I use it:

delayAjaxUpdate(li.json.id, 5000, $p(Chains.ajaxUpdate, li, json_data));

Beautiful :)

© Amir Salihefendic. Powered by Skeletonz.