ui.util.debounce
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यह फ़ंक्शन को रैप करता है, ताकि इसे बार-बार ट्रिगर किए गए कॉल के हर क्रम के लिए ज़्यादा से ज़्यादा एक बार कॉल किया जा सके. ऐसा तब तक किया जा सकता है, जब तक उन्हें तय किए गए इंटरवल (मिलीसेकंड में) से कम समय में ट्रिगर किया जाता है. इसका इस्तेमाल, किसी महंगे फ़ंक्शन के इनवोकेशन की संख्या को कम करने के लिए किया जा सकता है. साथ ही, यह पक्का किया जा सकता है कि वह फ़ंक्शन आखिर में चले.
इस्तेमाल का उदाहरण: ui.Checkbox पर बदलाव के इवेंट के लिए कॉलबैक. अगर उपयोगकर्ता चेकबॉक्स पर बार-बार क्लिक करता है, तो चेकबॉक्स पर किए गए सिर्फ़ आखिरी क्लिक पर कॉलबैक चलेगा.
यह फ़ंक्शन, डिबाउंस किया गया फ़ंक्शन दिखाता है.
इस्तेमाल | रिटर्न |
---|
ui.util.debounce(func, delay, scope) | फ़ंक्शन |
आर्ग्यूमेंट | टाइप | विवरण |
---|
func | फ़ंक्शन | डीबाउंस करने के लिए फ़ंक्शन. |
delay | नंबर | फ़ंक्शन को एक बार कॉल करने के बाद, उसे फिर से कॉल करने से पहले कितने मिलीसेकंड का इंतज़ार करना है. |
scope | ऑब्जेक्ट, ज़रूरी नहीं है | वह ऑब्जेक्ट जिसके स्कोप में फ़ंक्शन को कॉल करना है. |
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eDebounces a function, limiting its execution to at most once within a specified time interval, even with repeated calls.\u003c/p\u003e\n"],["\u003cp\u003eUseful for optimizing expensive functions triggered by frequent events, ensuring only the last call within the interval is executed.\u003c/p\u003e\n"],["\u003cp\u003eReturns a debounced version of the original function, which can be called directly.\u003c/p\u003e\n"],["\u003cp\u003eCustomizable with parameters like \u003ccode\u003edelay\u003c/code\u003e for setting the debounce interval and \u003ccode\u003escope\u003c/code\u003e for controlling the function's execution context.\u003c/p\u003e\n"]]],[],null,["# ui.util.debounce\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, once for each sequence of calls fired repeatedly so long as they are fired less than a specified interval apart (in milliseconds). This can be used to reduce the number of invocations of an expensive function while ensuring it eventually runs.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a change event on a ui.Checkbox. If the user clicks the checkbox repeatedly, only the last click of the checkbox will run the callback.\n\nReturns the debounced function.\n\n| Usage | Returns |\n|--------------------------------------------|----------|\n| `ui.util.debounce(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | The function to debounce. |\n| `delay` | Number | After the function is called once, the number of milliseconds to delay for an additional invocation of the function before allowing it to run. |\n| `scope` | Object, optional | Object in whose scope to call the function. |"]]