ui.util.throttle
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
تابعی را می پیچد تا اجازه دهد حداکثر دو بار در هر بازه فراخوانی شود. اگر تابع wrapper چندین بار قبل از سپری شدن تاخیر فراخوانی شود، فقط اولین و آخرین تماس انجام می شود.
مثال استفاده: برای پاسخ به تماس به یک رویداد اسلاید در یک ui.Slider. پاسخ تماس بلافاصله اجرا می شود و باعث می شود عمل اسلاید پاسخگو باشد. همچنین تضمین شده است که پس از پایان تعامل کاربر با لغزنده، تماس برگشتی اجرا شود و اطمینان حاصل شود که فراخوانی برگشت به تماس نهایی به مقدار نهایی اسلایدر دسترسی دارد.
تابع پیچیده شده را برمی گرداند.
استفاده | برمی گرداند | ui.util.throttle(func, delay, scope ) | تابع |
استدلال | تایپ کنید | جزئیات | func | تابع | تابع برای فراخوانی. |
delay | شماره | تاخیر، در میلی ثانیه، برای دریچه گاز. تابع را فقط می توان یک بار پس از فراخوانی اولیه تا پس از سپری شدن تاخیر فراخوانی کرد. |
scope | شیء، اختیاری | شیئی که در محدوده آن تابع فراخوانی شود. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eLimits a function's execution to at most twice per specified interval, ensuring responsiveness and capturing the final state.\u003c/p\u003e\n"],["\u003cp\u003eUseful for scenarios like UI slider events where immediate feedback and final value processing are crucial.\u003c/p\u003e\n"],["\u003cp\u003eWraps the original function and returns a new function that manages the throttling behavior.\u003c/p\u003e\n"],["\u003cp\u003eCustomizable with a delay parameter (in milliseconds) and an optional scope for execution context.\u003c/p\u003e\n"]]],[],null,["# ui.util.throttle\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, twice per interval. If the wrapper function is called multiple times before the delay elapses, only the first and the last calls will go through.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a slide event on a ui.Slider. The callback will run immediately, making the slide action feel responsive. The callback is also guaranteed to run after the user has finished interacting with the slider, ensuring that the final callback invocation has access to the slider's final value.\n\nReturns the wrapped function.\n\n| Usage | Returns |\n|--------------------------------------------|----------|\n| `ui.util.throttle(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | The function to call. |\n| `delay` | Number | The delay, in milliseconds, for the throttle. The function can only be called once after the initial invocation until after the delay has elapsed. |\n| `scope` | Object, optional | The object in whose scope to call the function. |"]]