إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ui.util.rateLimit
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تغليف دالة للسماح باستدعائها مرة واحدة على الأكثر في كل فاصل زمني إذا تم استدعاء دالة التغليف أكثر من مرة، سيتم تنفيذ الاستدعاء الأول فقط، ولن يكون لأي استدعاءات لاحقة أي تأثير إلى أن ينقضي الفاصل الزمني. يمكن استخدام ذلك لضمان تنفيذ دالة مكلفة على الفور ولكن بدون تنفيذها بشكل متكرر.
مثال على الاستخدام: لردّ الاتصال بنقرة على ui.Button، وذلك لمنع النقر المزدوج على الزر عن طريق الخطأ وتشغيل ردّ الاتصال مرّتين.
تعرض هذه الدالة الدالة التي تم تحديد معدّل استخدامها.
الاستخدام | المرتجعات |
---|
ui.util.rateLimit(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\u003eLimits a function's execution to at most once per specified interval, preventing rapid, repeated calls.\u003c/p\u003e\n"],["\u003cp\u003eUseful for optimizing expensive functions or preventing unintended double-click actions, such as on UI buttons.\u003c/p\u003e\n"],["\u003cp\u003eReturns a rate-limited version of the original function, accepting the function, delay, and optional scope as parameters.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes a delay mechanism to ensure subsequent calls are ignored until the interval has elapsed, guaranteeing controlled execution.\u003c/p\u003e\n"]]],[],null,["# ui.util.rateLimit\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, once per interval. If the wrapper function is called more than once, only the first call will go through, and no subsequent invocations will have an effect until the interval has elapsed. This can be used to ensure a function that is expensive to run executes immediately but doesn't execute repeatedly.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a click on a ui.Button, in order to prevent the button from being accidentally double-clicked and the callback running twice.\n\nReturns the rate-limited function.\n\n| Usage | Returns |\n|---------------------------------------------|----------|\n| `ui.util.rateLimit(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | Function to call. |\n| `delay` | Number | After the function is called and executed, the number of milliseconds to delay before allowing an additional invocation of the function. |\n| `scope` | Object, optional | Object in whose scope to call the function. |"]]