Popular Posts
Internal Table: declare types ARR type I occurs 10. " 定義長度為10的數值table/array types: begin of CONTACT, " 定義CONTACT為... Send mail tool using System; using System.Net.Mail; using System.Net; namespace Bruce.Mail {     public class MailFactory     {         private static Smt... Calculated Field Formulas Conditional formulas ...
Stats
Memo: Debounce Task

To prevent multi-execution from caller in short time, use debounce for single execution.

var debounce = function (func, threshold, execAsap) {
    var timeout;
    return function debounced () {
        var obj = this, args = arguments;
        function delayed () {
            if (!execAsap)
            func.apply(obj, args);
            timeout = null;
        };
        if (timeout)
            clearTimeout(timeout);
        else if (execAsap)
            func.apply(obj, args);
        timeout = setTimeout(delayed, threshold || 100);
    };
}