إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ui.util.debounce
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تغليف دالة للسماح باستدعائها مرة واحدة على الأكثر لكل تسلسل من عمليات الاستدعاء التي يتم تنفيذها بشكل متكرر طالما يتم تنفيذها بفارق أقل من فاصل زمني محدد (بالملي ثانية). يمكن استخدام ذلك لتقليل عدد استدعاءات دالة مكلفة مع ضمان تشغيلها في النهاية.
مثال على الاستخدام: لردّ الاتصال بحدث تغيير في ui.Checkbox. إذا نقر المستخدم على مربّع الاختيار بشكل متكرّر، سيتم تنفيذ وظيفة معاودة الاتصال عند النقر الأخير على مربّع الاختيار فقط.
تعرض هذه الدالة الدالة التي تم تأخير تنفيذها.
الاستخدام | المرتجعات |
---|
ui.util.debounce(func, delay, scope) | الوظيفة |
الوسيطة | النوع | التفاصيل |
---|
func | الوظيفة | الدالة التي سيتم إزالة التكرار منها |
delay | العدد | بعد استدعاء الدالة مرة واحدة، يتم تحديد عدد الملّي ثانية التي يجب الانتظار خلالها قبل السماح بتنفيذ الدالة مرة أخرى. |
scope | الكائن، اختياري | الكائن الذي سيتم استدعاء الدالة في نطاقه. |
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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. |"]]